How can I define a NSString with name "media:thumbnail", it's giving me an error.
error:bit-field 'media' has invalid type
.
How can I define a NSString with name "media:thumbnail", it's giving me an error.
error:bit-field 'media' has invalid type
.
The colon (":") is a reserved character in C, C++, and Objective-C and cannot be used in identifiers. http://eli-project.sourceforge.net/c_html/c.html#s6.1.2 Try NSString *media_thumbnail = @"your NSString text";
If you want to match the key value with your xml then there is a string replace function in objecitve c like this.
NSString *strval = [xmlstrval stringByReplacingOccurrencesOfString:@":" withString:@"_"];
Now strval is the value of name of the variable "media_thumbnail".
Regards,
Ruchir Shah
http://ruchirshah.in
or
etc.
You seem to be confusing the identifier of an object i.e. the human readable symbolic representation of it's memory address, with its value.
In this case...
NSString *steve=@"steve";
... the first "steve" is just the identifier. The complier uses it to mark a location in memory so that it can be easily accessed in code. The second "steve" is the value and bears absolutely no relation to the identifier. Neither steve is required for the other one. For example...
NSString *bob=@"steve";
and
NSString *steve=@"bob";
... are equally valid and completely seperate objects.
As noted here by others, the colon character is a reserved character used to indicate logical operations. You can't use it in a identifier. This...
NSString *media:thumbnail=@"someValue";
... gives you the error message because the complier sees...
address-of-a-NSString with identifier "media" bitwise by identifier "thumbnail" equals address-of-a-NSString with value of "someValue".
You don't need a particular identifier name for the string to identify a value taken from xml. Any legal name will do.
It sounds like you need to associate the xml label "media:thumbnail" with a particular value. In that case you need a dictionary like so:
NSMutableDictionary *myDict=[[NSMutableDictionary alloc] initWithCapacity:1];
[myDict setValue:@"someXMLvalue" forKey:@"media:thumbnail"];
NSString *myThumbnail=[myDict valueForKey:"media:thumbnail"];