|Dec 3, 2005, 10:53 PM||#1|
Compiler Warnings: id and *id, multiple declarations
What syntax do I need so the XCode compiler accepts both id and id* types without giving me warnings? Although the compiler warnings don't turn into exceptions that stop my program in it's tracks or change my program logic, I heard it's good practice to remove all warnings and want to remove the warnings.
Since I'm on the topic of removing warnings, I can't seem to get rid of these kinds of warnings either.
I've only declared -(NSString *)set once:
[[sets objectAtIndex:i] omega:[[[sets objectAtIndex:i] set] length]-1]; warning: multiple declarations for method `set'
I never did declare -(int)length, so I don't know why it doesn't know what the heck is going on, since -(int)length is an NSString method.
[self possible:[self possible] * [[[sets objectAtIndex:i] set] length]]; warning: multiple declarations for method `length'
|Dec 4, 2005, 04:19 AM||#2|
You can't. A method in an ObjC class cannot be overloaded like it can in C++. You can't do what you are trying to do.
Why do you want to be able to pass id* anyway? id is already a pointer (it's declared as void* or obj_class* anyway).
Sponsor me to cycle 100Km round London in the dark
|Dec 4, 2005, 07:55 PM||#3|
I don't know what overloading is, but what I did describe up there worked fine, just got warnings.
Why id*? For the same reason of NSArray method:
- (id)initWithObjects:(id *)objects count:(unsigned)count
I did figure out the first part of the question. I just made my id an id*.
But I still don't know why I'm getting those others warnings, I bet it's something really simple.
|Dec 5, 2005, 03:44 AM||#5|
- (id)initWithObjectsid *)objects countunsigned)count
Although it's possible to do stuff yourself like the above in objective-C it's much more common to send a group of objects in an array or a dictionary (depending upon your needs). Something like
[myObject myMethodWithArray:[NSArray arrayWithObjects: one, two, three, nil]];
Although my example is obviously more verbose and slower when you only ever use immutable objects I think the method is much more flexible if it can take any old array not just a list of objects. You also get to use the NSArray methods to access the elements rather than messing about with pointer arithmetic.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Application warnings||harrybaker||Mac Basics and Help||10||May 6, 2013 09:16 AM|
|USB warnings on wake up||digitalfailure||OS X 10.8 Mountain Lion||3||Apr 5, 2013 10:44 AM|
|Application warnings||martymcgee||OS X 10.8 Mountain Lion||0||Mar 26, 2013 04:00 PM|
|Another multiple ID, multiple device, multiple phone number iMessage question||mrcalabash||iOS 6||3||Jan 12, 2013 08:45 PM|
|iPad Mini: PLEASE! WAIT!~All these case warnings, here's why....||glen e||iPad Accessories||27||Nov 8, 2012 11:00 AM|
All times are GMT -5. The time now is 09:20 PM.