Skip to content

Instantly share code, notes, and snippets.

View thatswiftguy's full-sized avatar
🎯
Focusing

Yasir thatswiftguy

🎯
Focusing
View GitHub Profile
@thatswiftguy
thatswiftguy / Task.swift
Created April 11, 2021 10:41
Task Model for TaskManager Application
//
// TaskModel.swift
// TaskManager
//
// Created by Mohammad Yasir on 11/04/21.
//
import Foundation
import SwiftUI
import UIKit
enum WeatherStateImage : CaseIterable {
static let sun = UIImage(systemName: "sun.min")
static let cloud = UIImage(systemName: "cloud")
static let rainingCloud = UIImage(systemName: "cloud.drizzle")
}
import UIKit
enum Dice {
case one
case two
case three
case four
case five
case six
}
@thatswiftguy
thatswiftguy / instance.swift
Created February 20, 2021 05:21
Creating an instance of book structure
struct Book {
var title : String
var pages : Int
var chapters : Int
}
var book = Book(title: "The Swift Book", pages: 1030, chapters: 12)
print(book.pages)
@thatswiftguy
thatswiftguy / structLook.swift
Created February 20, 2021 05:14
How structures looks in swift programming
struct Book {
// Properties
// Methods
}
@thatswiftguy
thatswiftguy / ListOfRecordings.swift
Created February 14, 2021 08:33
This is the List of Recordings
import SwiftUI
struct recordingListView: View {
@ObservedObject var vm = VoiceViewModel()
var body: some View {
NavigationView {
VStack {
ScrollView(showsIndicators: false){
@thatswiftguy
thatswiftguy / ContentView.swift
Last active February 14, 2021 08:32
This is main view of our app
struct ContentView: View {
@ObservedObject var vm = VoiceViewModel()
@State private var showingList = false
@State private var showingAlert = false
var body: some View {
ZStack{
func deleteRecording(url : URL){
do {
try FileManager.default.removeItem(at : url)
} catch {
print("Can't delete")
}
for i in 0..<recordingsList.count {
@thatswiftguy
thatswiftguy / StartPlaying.swift
Last active January 14, 2023 08:12
This Function will Play the Audio
func startPlaying(url : URL) {
let playSession = AVAudioSession.sharedInstance()
do {
try playSession.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)
} catch {
print("Playing failed in Device")
}
@thatswiftguy
thatswiftguy / FetchAllRecording.swift
Created February 13, 2021 15:44
This Function Will Fetch the All Recordings from system to Array
func fetchAllRecording(){
let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let directoryContents = try! FileManager.default.contentsOfDirectory(at: path, includingPropertiesForKeys: nil)
for i in directoryContents {
recordingsList.append(Recording(fileURL : i, createdAt:getFileDate(for: i), isPlaying: false))
}
recordingsList.sort(by: { $0.createdAt.compare($1.createdAt) == .orderedDescending})