Any good advice for naming parameters of init methods?
Any good advice for naming parameters of init methods?
- Subject: Any good advice for naming parameters of init methods?
- From: an0 <email@hidden>
- Date: Thu, 10 Jul 2008 22:25:05 +0800
I've been always stumbling on the embarrassment of "warning: local
declaration of 'xxx' hides instance variable" for my init methods,
because I really can't figure out a nice naming pattern for parameters
used to assign to instance properties, and I am always apt to write
code like this:
- (id)initWithURL:(NSString *)url title:(NSString *)title
tags:(NSString *)tags note:(NSString *)note time:(NSString *)time
count:(NSUInteger)count
since it is most natural(to me). Then I just see XCode spew out lots
of annoying warnings like these:
Line Location Post.m:28: warning: local declaration of 'url' hides
instance variable
Line Location Post.m:28: warning: local declaration of 'url' hides
instance variable
Line Location Post.m:29: warning: local declaration of 'title' hides
instance variable
Line Location Post.m:29: warning: local declaration of 'title' hides
instance variable
Line Location Post.m:32: warning: local declaration of 'time' hides
instance variable
Line Location Post.m:32: warning: local declaration of 'time' hides
instance variable
Line Location Post.m:30: warning: local declaration of 'tags' hides
instance variable
Line Location Post.m:30: warning: local declaration of 'tags' hides
instance variable
Even though I then follow the general naming rules to prepend an
indefinite article to each singular noun, I still have those plural
nouns sitting there, which now looks this:
- (id)initWithURL:(NSString *)aUrl title:(NSString *)aTitle
tags:(NSString *)tags note:(NSString *)aNote time:(NSString *)aTime
count:(NSUInteger)aCount
Set aside the oddness of aTime and aCount, my XCode still complain:
Line Location Post.m:30: warning: local declaration of 'tags' hides
instance variable
Line Location Post.m:30: warning: local declaration of 'tags' hides
instance variable
Am I supposed to use something like aGroupOfTags instead of just tags?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden