News for hackers. Stuff that matters.
Re:Cargo-cult typing, or: Objective-C's default type is id by wsc981 on Wednesday March 05, 2014 @06:23PM (#7350720)
Somewhat unrelated ...

I wish Apple would add local type inference to Objective-C, perhaps using the existing id type or some keyword like var in C#. It would make the code so much more quicker to write, less verbose, a bit easier to change.

I mean reading and writing something like:

    var color = [UIColor green];
    var viewController = [[MyViewController alloc] initWithBackgroundColor:color];
Is so much more pleasant as:

    UIColor *color = [UIColor green];
    MyViewController *viewController = [[MyViewController alloc] initWithBackgroundColor:color];
Re:Cargo-cult typing, or: Objective-C's default type is id by mpweiher on Thursday March 06, 2014 @02:45AM (#7352423)
You could just write:

   id color = [UIColor green];
   id viewController = [[MyViewController alloc] initWithBackgroundColor:color];
The UIColor* is largely there for your benefit, for the compiler it makes hardly a difference (pre ARC). If you don't find it a benefit, just leave it out.
Re:Cargo-cult typing, or: Objective-C's default type is id by wsc981 on Thursday March 06, 2014 @08:39AM (#7353552)
Problem with using id is that it has no knowledge of type information. Xcode wont be able to autocomplete. This in contrast with using the var keyword in C#.
Re:Cargo-cult typing, or: Objective-C's default type is id by mpweiher on Friday March 07, 2014 @12:12PM (#7361381)
As I wrote: it's there for your benefit...