Live data from Hacker News

Clean, Modern Objective-C

harlanhaskins.com

1–10 of 48 posts

Re: Clean, Modern Objective-C

#2
I'm surprised that he provides five versions of the method definition syntax and none of them are what Apple does and what I consider to be the standard:

    - (void)doSomethingWithParameter:(NSString *)parameter;

Re: Clean, Modern Objective-C

#3
I'm guilty of #4, but I think it's a judgement thing. If you're just going to briefly use the dictionary, I personally think it's a waste of time to go to the effort of creating a class. If it's core to your program it makes more sense since you can then tap into things like KVO a bit better. And, prior to ARC and automatic synthesis of properties, it made for a ton of boilerplate code.

Re: Clean, Modern Objective-C

#4
post #2

I'm surprised that he provides five versions of the method definition syntax and none of them are what Apple does and what I consider to be the standard: - (void)doSomethingWithParameter:(NSString *)parameter;

That's what I use as well. In Apple's frameworks I've found them to be very inconsistent between different areas though.

Re: Clean, Modern Objective-C

#5
post #2

I'm surprised that he provides five versions of the method definition syntax and none of them are what Apple does and what I consider to be the standard: - (void)doSomethingWithParameter:(NSString *)parameter;

That is the convention officially endorsed by Apple (https://developer.apple.com/library/ios/documentation/Cocoa/...)

Re: Clean, Modern Objective-C

#6
post #2

I'm surprised that he provides five versions of the method definition syntax and none of them are what Apple does and what I consider to be the standard: - (void)doSomethingWithParameter:(NSString *)parameter;

You're correct. I've updated the post with credit to you, thanks!

Re: Clean, Modern Objective-C

#7
post #2

I'm surprised that he provides five versions of the method definition syntax and none of them are what Apple does and what I consider to be the standard: - (void)doSomethingWithParameter:(NSString *)parameter;

You're correct. I've updated the post with credit to you, thanks!

No problem! Have you commonly come across all these variations? I have seen a couple different things but my experience working in objective-c written by others has been limited, so my impression was that the above was more widely accepted.

Re: Clean, Modern Objective-C

#8
post #7

Earlier quoted context omitted.

You're correct. I've updated the post with credit to you, thanks!

No problem! Have you commonly come across all these variations? I have seen a couple different things but my experience working in objective-c written by others has been limited, so my impression was that the above was more widely accepted.

I contribute to CocoaPods repositories, so I've seen a lot. I don't really feel adamantly one way or the other, but just be consistent.

Re: Clean, Modern Objective-C

#9
post #2

I'm surprised that he provides five versions of the method definition syntax and none of them are what Apple does and what I consider to be the standard: - (void)doSomethingWithParameter:(NSString *)parameter;

That is my preferred method as well, but I've seen a lot of templates use:

-(void) doSomethingWithParameter:(NSString *)parameter;

Post reply on HN