JSON 문자열을 생성하는 데 사용하는 PLIST에서 문자열 데이터를 읽는 중입니다. (부수적으로 Facebook Connect에서 사용하기 위해).NSString을 구문 분석하여 Xcode 내에서 올바르게 구성된 JSON 문자열을 확인하십시오.
NSString *eventLink = [eventDictionary objectForKey:EVENT_FIND_OUT_MORE_KEY];
NSString *eventLinkEscaped = [eventLink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *eventName = [eventDictionary objectForKey:EVENT_NAME_KEY];
NSString *eventDescription = [eventDictionary objectForKey:@"Description"];
NSString *eventImageAddress = [eventDictionary valueForKey:@"Image URL"];
if ([eventImageAddress length] == 0)
{
eventImageAddress = NO_EVENT_IMAGE_URL;
}
// Publish a story to the feed using the feed dialog
FBStreamDialog *facebookStreamDialog = [[[FBStreamDialog alloc] init] autorelease];
facebookStreamDialog.delegate = self;
facebookStreamDialog.userMessagePrompt = @"Publish to Facebook";
facebookStreamDialog.attachment =[NSString stringWithFormat: @"{\"name\":\"%@\",\"href\":\"%@\",\"description\":\"%@\",\"media\":[{\"type\":\"image\",\"src\":\"%@\",\"href\":\"%@\"}]}", eventName, eventLinkEscaped, eventDescription, eventImageAddress, eventLinkEscaped];
[facebookStreamDialog show];
이 모든 기능은 제대로 작동하지만 대화 상자에 나타나는 텍스트가 공백 인 특정 이벤트 설명 (약 4 개 중 4 개)이 있습니다. 명백한 후보자를 찾았습니다. 즉, 설명에 "문자 또는 인스턴스가 포함되어 있습니다. 저작권 기호가 있습니다. 제 질문은 stringByAddingPercentEscapesUsingEncoding과 같은 쉬운 메서드 호출이 있습니까? NSUTF8StringEncoding은 모든 도기 문자가 이스케이프되거나 무시되도록합니다. 사전에
감사합니다,
데이브
사실 더 자세한 조사에서 저작권 기호는 실제로 2 개의 이벤트와 "2의 문자"에 대한 텍스트에서 잘 나타났습니다. –