user1427835
user1427835

Reputation: 31

Objective C IOS class variable called "id"

Can i call a class variable "id" (for example NSString *id)? Everything seems to work, except that i cannot make [id release] in dealloc method. I'm creating instances of this class from a XML parser using object/key construct so i need this to be called id. I've tried [self.id release] and everthing works, except that the analyzer shows me a warning saying "Property returns an Objective-C object with a +0 retain count" and "Incorrect decrement of the reference count of an object that is not owned at this point by the caller". So i'm wondering if i'm doing something illegal. Thank you very much.

Upvotes: 1

Views: 3216

Answers (3)

jrturton
jrturton

Reputation: 119242

Don't do it.

  • It's a meaningless name - the ID of what?
  • It clashes with a language keyword and is bound to have some unwanted effects somewhere
  • It hurts readability, people will have to wonder what you are referring to at any point in the code

Upvotes: 1

James Webster
James Webster

Reputation: 32066

id is a keyword in objective-c. It's a weak type variable identifier, similar to var in javascript.

Upvotes: 2

Dan F
Dan F

Reputation: 17732

id in objective-c is a predefined type. You should probably name it something different, like idString

It is the same thing as attempting to name a variable int or another objective-c keyword like if

Upvotes: 3

Related Questions