Linked by Jared White on Thu 24th Apr 2003 17:49 UTC
Permalink for comment
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
News
Linked by Thom Holwerda on 06/19/13 23:02 UTC, submitted by M.Onty
Linked by Thom Holwerda on 06/19/13 22:28 UTC
Linked by Thom Holwerda on 06/18/13 22:33 UTC
Linked by Anonymous on 06/18/13 22:26 UTC
Linked by Thom Holwerda on 06/18/13 22:25 UTC
Linked by Thom Holwerda on 06/18/13 17:45 UTC
Linked by Thom Holwerda on 06/18/13 17:32 UTC, submitted by poundsmack
Linked by Thom Holwerda on 06/17/13 17:58 UTC
Linked by Thom Holwerda on 06/17/13 17:52 UTC
Linked by Thom Holwerda on 06/14/13 21:03 UTC
More News »
Sponsored Links



Messages to nil (or the Nil class) normally return nil (some runtimes allow this behavior to be easily modifed. This allows you set up a big chain of messages and only worry if the final result is nil:
foo = [[[[NSData alloc] initWithContentsOfFile: @"my.data"] autorelease] md5];
You don't have to deal with types in ObjC the same way you're think of. Every object *does* have a type/class it belongs to, but you need not worry yourself over the particulars to perform an operation. If you have a collection that responds to -addObject:, that is enough; why sweat over it being an array, set, linked list, whatever?
In some runtimes it *is* possible to create objects on the stack. That is not part of common systems, so clearly there is little benefit to it in the real world.
As far as syntax issues go, some of you people simply need more exposure. A professional programmer should be able to get beyond syntax issues relatively easily, and ObjC has the most minor of syntax differences from C. For your example, the equivalent Cocoa code would be:
[v addObject: [NSNumber numberWithInt: 1]];
Hardly a difficult read. Where the ObjC syntax really shines is with multiple arguments. Compare:
new Account("Steve", 50, 32, "Phil")
with
[Account accountWithOwner: @"Steve" age: 50 startingBalance: 32 accountManager: @"Phil"]
I'd much rather come across the later in code I had to maintain.