How can i convert the key to an NSNumber? this code gives me the error:
no matter how i try it, i always end up with the error: Incompatible integer to pointer conversion assigning to ‘NSNumber’ from ‘NSIntegar’ (aka ‘int’).
for (id key in consultants)
{
consultantData = [[ConsultantData alloc] init];
consultantData.name = [consultants objectForKey:key];
consultantData.conID = [[NSNumber numberWithInteger:key] integerValue];
NSLog(@"name: %@ ID: %@", consultantData.name, consultantData.conID);
[consultantList addObject:consultantData];
[consultantData release];
}
here is my object ConsultantData:
#import <Foundation/Foundation.h>
@interface ConsultantData : NSObject
{
NSString *name;
NSNumber *conID;
}
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSNumber *conID;
@end
#import "ConsultantData.h"
@implementation ConsultantData
@synthesize name;
@synthesize conID;
-(void) dealloc
{
[name release];
[conID release];
[super dealloc];
}
@end
if i try isMemberOfClass, it never returns true. if i try isKindOfClass, it tells me its a NSString.
consultants is a dictionary i receive from my sever that passes thru an XMLRPC function (server is PHP). from what i’ve seen, everything is a string in the server dictionary returns.
could be that you have the order wrong.
means
you probably want
which is in verbose form: