Comparing C and Objective-C

The key difference between C and Objective-C is that Objective-C deals only with objects. You can include C data types in Objective-C code, but if you want to integrate them with Objective-C objects—for example, if you want to store numbers in an NSArray object—you must “objectify” them first by wrapping them inside an object. Full details are moderately complex and outside the scope of this book. For more information, see Cocoa in Wiley’s Developer Reference series.

Note also that Objective-C includes denser and more abstract options than C. For example, you can use automatic enumeration to loop through every object in an array and run code on each object repeatedly. The enumeration works even when the array contains objects of different types. For details and example code, see the NSArray class reference.

Get iOS App Development Portable Genius now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.