Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift vs. Objective-C

Swift vs. Objective-C

Not really an epic battle.

Ben Kreeger

December 05, 2014
Tweet

More Decks by Ben Kreeger

Other Decks in Programming

Transcript

  1. - (void)updateWithDictionary:(NSDictionary *)dictionary context:(NSManagedObjectContext *)context { [self.remoteToLocalAttributeMap each:^(NSString *remoteName, NSString

    *localName) { id remoteValue = dictionary[remoteName]; if ([(NSNull *)remoteValue isEqual:[NSNull null]]) return; if (self.remoteDateFormats[remoteName]) { remoteValue = [NSDate dateFromString:remoteValue format:self.remoteDateFormats[remoteName]]; } [self setValue:remoteValue forKeyPath:localName]; }]; } (Yes, this is fun)
  2. private func createOrUpdateLocations(dicts: [NSDictionary]) -> [SaucerLocation] { let realm =

    RLMRealm.defaultRealm() var locations = [SaucerLocation]() realm.transactionWithBlock() { for dict in dicts { var instance = SaucerLocation.findOrCreate(dictionary: dict, inRealm: realm) locations.append(instance) } } return locations }
  3. ▸ Compiler has a couple of bugs ▸ Works with

    90% of UIKit/Foundation well ▸ CocoaPods support forthcoming ▸ Banner features still need some TLC