Skip to content

Instantly share code, notes, and snippets.

View myawesomehub's full-sized avatar
💛
Exploring

Mohammad Yasir myawesomehub

💛
Exploring
View GitHub Profile
```
import Foundation
struct mySortedArray<T: Comparable> {
// We are Creating an Array and intialise it
var array = [T]()
init(array: [T]) {
self.array = array.sorted()
}
@myawesomehub
myawesomehub / 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})
func deleteRecording(url : URL){
do {
try FileManager.default.removeItem(at : url)
} catch {
print("Can't delete")
}
for i in 0..<recordingsList.count {
@myawesomehub
myawesomehub / 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{
@myawesomehub
myawesomehub / 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){
@myawesomehub
myawesomehub / structLook.swift
Created February 20, 2021 05:14
How structures looks in swift programming
struct Book {
// Properties
// Methods
}
@myawesomehub
myawesomehub / 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)
import UIKit
enum Dice {
case one
case two
case three
case four
case five
case six
}
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")
}
@myawesomehub
myawesomehub / 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