views:

28

answers:

2

I'm trying to bring data into my app from an external file. everything's working until I add the event.title (the 3rd objectAtIndex below). I think I'm incorrectly using "stringValue" and it should be something else. the floatValues work fine.

event.latitude = [[values objectAtIndex:0] floatValue];

event.longitude = [[values objectAtIndex:1] floatValue];

event.title = [[values objectAtIndex:2] stringValue];

here's the header file code:

    float latitude;
    float longitude;
    NSString *title;
}

@property (nonatomic) float latitude;
@property (nonatomic) float longitude;
@property (nonatomic, copy) NSString *title;

thanks in advance.

+2  A: 

For strings, you don't need to get stringValue or anything. floatValue is for NSNumber, but you already have a plain NSString.

event.title = [values objectAtIndex:2];
jtbandes
that worked! thanks so much
hanumanDev
A: 

How is the string stored in the file, and how are you reading the file?

I would assume you can just drop the stringValue method and directly assign the return from objectAtIndex: - assuming the object is read in as a string.

Jasarien
dropping the stringValue worked. thanks.
hanumanDev
Glad to know it worked hanumandev. You should mark either jtbandes or my answer as accepted, as I see your accept rate is 0%. If you don't accept answers to your questions, people will have no incentive to answer your future questions. To mark an accepted answer, click the tick mark next to the answer.
Jasarien
ok, thanks for pointing that out. i didn't see that option before.
hanumanDev