ObjectiveCTips's profile picture.

ObjectiveC

@ObjectiveCTips

Private Public Protected access modifiers are present in Objective C ideone.com/3em2D


Objective-C has a java interface equivalent called @protocol


Categories allow you to add functionality to already existing classes without extending them.


The following program demonstrates constructor, reference counting etc., ideone.com/Oad7A


Here is an e.g. of property and using @synthesize ideone.com/GmqHM ignore errors though


ideone.com/NsuFP is a complete example comprising of an interface implementation, allocate, initialize,method invocation


[obj morebar: 250] is how you would invoke a method morebar which takes a parameter int on the object obj.


[obj bar] will invoke a method bar on the object obj


id obj = [[foo alloc] init]; will allocate and initialize an object of type foo


customer.name = @"ACME Corporation"; output = ; is how you invoke the setters and getters


All instance variables are private in Objective-C by default, write getters and setters Use @synthesize directive to autogenerate these


All Objective-C object variables are pointers types. The id type is predefined as a pointer types, sort of like your void *


- before a method name means it's an instance method. + before a method name means it's a class method.


nil object is the functional equivalent of the null pointer without the crashing part


The implementation of these methods is stored in <classname.m> e.g., foo.m. You could define methods in foo.m but is considered unsupported


The class interface is usually stored in a file <classname.h> for instance, foo.h and defines instance variables and public methods


Cocoa is the application framework library


此帐户目前未关注任何人

United States 趋势

Loading...

Something went wrong.


Something went wrong.