Re: Any good advice for naming parameters of init methods?
Re: Any good advice for naming parameters of init methods?
- Subject: Re: Any good advice for naming parameters of init methods?
- From: Steve Nicholson <email@hidden>
- Date: Thu, 10 Jul 2008 07:41:20 -0700
On Jul 10, 2008, at 7:25 AM, an0 wrote:
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?
"someTags"?
I'd probably use "inTags"
-Steve
_______________________________________________
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