如何在目标c中将字符串转换为int

shr*_*evi 0 iphone

我想在地图中显示注释.我有字符串格式的lat和longi.现在我只需将其转换为int.

    NSString *s= @"18.65799";
    location1.latitude =[s intValue];
    NSLog(@"1%d",[s intValue]);
            NSString *s1= @"73.774262";
    location1.longitude=[s1 intValue];
Run Code Online (Sandbox Code Playgroud)

但是当我显示[s intValue]时,输出为118. NSLog的输出(@"1%@",location1.latitude)为空;

请帮忙.

Mar*_*ers 5

更改:

NSLog(@"1%d",[s intValue]);
Run Code Online (Sandbox Code Playgroud)

至:

NSLog(@"%d", [s intValue]);
Run Code Online (Sandbox Code Playgroud)

同样对于s1:

NSLog(@"%d", [s1 intValue]);
Run Code Online (Sandbox Code Playgroud)