나는 당신의 질문에 완전히 명확하지,하지만 당신은 CLLocationCoordinate2D 내로 있는 NSString 변환하고자하는 경우 다음과 같은 사용할 수 있습니다
이
{
[self useLocationString:@"19.14,73.10"];
}
- (void) useLocationString:(NSString*)loc
{
// the location object that we want to initialize based on the string
CLLocationCoordinate2D location;
// split the string by comma
NSArray * locationArray = [loc componentsSeparatedByString: @","];
// set our latitude and longitude based on the two chunks in the string
location.latitude = [[[NSNumber alloc] initWithDouble:[[locationArray objectAtIndex:0] doubleValue]] autorelease];
location.longitude = [[[NSNumber alloc] initWithDouble:[[locationArray objectAtIndex:1] doubleValue]] autorelease];
// do something with the location
}
이 코드는 유효성을 검사하지 않습니다 당신이 할 수있는 문자열의 NSArraycomponentsPeparatedByString에서 돌아 오면 확인할 수 있습니다.
내가 거기서 생각하는 언어가 일치하지 않습니다. '[self useLocationString : @ "19.14,73.10"]' – dreamlax
@dreamlax 고마워 ;;) 내가 자주 내가 어떻게하는지 우스꽝 스럽다. – RedBlueThing
당신은 또한 마지막 줄에 = 대신 ==를 붙입니다;) –