because Ruby and Objective-C has the same ancestor, they have many things in common, and in this talk I mainly talk about what I learned in Ruby, borrow those experiences and move to Objective-C :)
object model dog = Dog.new ! puts "class of dog is #{dog.class}” # Dog puts "superclass of dog is #{dog.class.superclass}” # Animal puts "super superclass of dog is #{dog.class.superclass.superclass}” # Object puts "super super superclass of dog is #{dog.class.superclass.superclass.superclass}” # BasicObject ! puts "class of Dog is #{Dog.class}” # Class puts "class class of Dog is #{Dog.class.class}” # Class puts "class of Animal is #{Animal.class}” # Class puts "class of Object is #{Object.class}” # Class
object model Dog* dog = [[Dog alloc] init]; ! NSLog(@"class of dog is %@", [dog class]); # Dog ! NSLog(@"superclass of dog is %@", [dog superclass]); # Animal ! NSLog(@"super superclass of dog is %@", [[dog superclass] superclass]); # NSObject ! NSLog(@"super super superclass of dog is %@", [[[dog superclass] superclass] superclass]); # null
sending message class Bank def save(money) puts "you just saved #{money} dollars" end end ! bank = Bank.new bank.save 20 # you just saved 20 dollars bank.send(:save, 20) # you just saved 20 dollars
iteration class Fox def say puts "what does the fox say?" end end ! fox1 = Fox.new fox2 = Fox.new fox3 = Fox.new foxes = [fox1, fox2, fox3] ! foxes.map { |fox| fox.say } # what does the fox say?
Objective-C : cocoapods platform :ios, '6.0' ! pod 'Facebook-iOS-SDK', '~> 3.5.1’ pod 'JSONKit', '~> 1.5pre' pod 'MagicalRecord', '~> 2.0.7’ pod 'SSKeychain', '~> 0.1.4’ pod 'TestFlightSDK', '~> 1.1' pod 'SMCalloutView', '~> 1.1.2' ! target :UnitTests do link_with 'UnitTests' pod 'OCMock', '~> 2.0.1' pod 'OCHamcrest', '~> 1.9' end
⾼高⾒見⻯⿓龍 Contacts photo by Eddie Website Blog Plurk Facebook Google Plus Twitter Email Mobile http://www.eddie.com.tw http://blog.eddie.com.tw http://www.plurk.com/aquarianboy http://www.facebook.com/eddiekao http://www.eddie.com.tw/+ https://twitter.com/#!/eddiekao [email protected] +886-928-617-687