This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import CoreData | |
extension MyCoredataObject { | |
@nonobjc public class func createFetchRequest() -> NSFetchRequest<MyCoredataObject> { | |
return NSFetchRequest<MyCoredataObject>(entityName: "MyCoredataObject") | |
} | |
@NSManaged public var sortId: Int64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
var stringOne = "Hello llollo" | |
var stringTwo = "" | |
stringOne.isEmpty | |
stringTwo.isEmpty | |
stringOne == "Hello llollo" | |
stringOne == "hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum TestPhases { | |
case Beta | |
case Alpha | |
case Stable | |
} | |
enum TestPhasesNew: String { | |
case Beta = "Beta :)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum Product { | |
case Book(Int, String) | |
case Car(Int, Int, String) | |
} | |
let AhmadShahBook = Product.Book(10, "Ahmad Shah") | |
switch AhmadShahBook { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alamofire.request(urlString).responseJSON { response in | |
guard case let .failure(error) = response.result else { return } | |
if let error = error as? AFError { | |
switch error { | |
case .invalidURL(let url): | |
print("Invalid URL: \(url) - \(error.localizedDescription)") | |
case .parameterEncodingFailed(let reason): | |
print("Parameter encoding failed: \(error.localizedDescription)") | |
print("Failure Reason: \(reason)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myGroup = DispatchGroup() | |
var result = [Data]() | |
for i in 0 ..< 5 { | |
myGroup.enter() | |
Alamofire.request("https://httpbin.org/get", parameters: ["foo": "bar"]).responseJSON { response in | |
print("Finished request \(i)") | |
result.append(response.data) | |
myGroup.leave() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//** simple form | |
// simple | |
let clos1 = { () -> Void in | |
print("Hello World!") | |
} | |
clos1() | |
// simple 2 | |
let clos2 = { (name: String) -> Void in | |
print("Hello \(name)!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let guests = ["Ahmad", "Mohsen", "Ehsan"] | |
// map closure | |
guests.map { | |
print("Hello \($0)") | |
} | |
let messages = guests.map { (name) -> String in | |
return name + "!" | |
} | |
print(messages) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Text like this appears in "Description". | |
/// | |
/// Leave a blank line to separate further text into paragraphs. | |
/// | |
/// You can use bulleted lists (use `-`, `+` or `*`): | |
/// | |
/// - Text can be _emphasised_ | |
/// - Or **strong** | |
/// | |
/// Or numbered lists: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSString *) getCarrierName | |
{ | |
CTTelephonyNetworkInfo *netinfo = [[CTTelephonyNetworkInfo alloc] init]; | |
CTCarrier *carrier = [netinfo subscriberCellularProvider]; | |
NSString *carrierName = [carrier carrierName]; | |
if (carrierName == nil) { | |
return @"unknown"; | |
} |
OlderNewer