2014-02-28 1 views
1

WS를 호출하면 응답이 NSData이됩니다. 나는 newStr 인쇄 할 때배열의 NSData 응답을 변환하십시오.

NSString* newStr = [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding]; 
NSLog(@"newStr = %@",newStr); 

가 :

newStr = 
f file1.txt 
f file2.txt 
f abc.txt 
F folder1 
F folder2 
f file3.txt 
f file4.txt 
F folder3 

를 내가의 콘텐츠와 UITableView를 채울 필요가

data = <66096669 6c65312e 7478740a 66096669 6c65322e 7478740a 66096162 632e7478 740a4609 666f6c64 6572310a 4609666f 6c646572 320a6609 66696c65 332e7478 740a6609 66696c65 342e7478 740a4609 666f6c64 657233> 

내가있는 NSString에 대한 응답 변환 : 나는 reuqest를 인쇄 NSString 및 문자열 내용을 추가하려면 NSSArray 소개해야합니다. 당신이 당신의 질문을있는 NSString에 대한 설명서가 응답 될 것이다 검토 경우

+1

처럼 배열에 있는 NSData 응답을 변환 할 수 있습니다. –

+3

정보 주셔서 감사합니다! self.dataSourceArray = [newStr componentsSeparatedByString : @ "\ n"];을 사용하여 문제를 해결합니다. –

+0

잘 했어 !! –

답변

0

직접이

NSError* error; 
    if (responseData != nil){ 
    NSMutableArray* json = [NSJSONSerialization JSONObjectWithData:responseData //1 
                 options:0 
                 error:&error]; 

    NSLog(@"%@",json); 

    }