아래 코드를 작성하고 있습니다.구문 분석 값을 얻는 방법?
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions error:&error];
NSLog(@"%@",json);
인쇄 사전 .... 등
(
{
Contents = (
{
Id = 2;
LastUpdated = "/Date(1338048712847+0000)/";
Title = "Webinar: HP & MS solutions for Mid-Market";
Url = "http://infra2apps.blob.core.windows.net/content/VMMM019-HP-MS_MidMarket.wmv";
},
{
Id = 1;
LastUpdated = "/Date(1338048712773+0000)/";
Title = "Webinar: Private Cloud with HP & MS";
Url = "http://infra2apps.blob.core.windows.net/content/VMPC012-HPMS_PrivateCloud.wmv";
}
);
Id = 1;
ImageUrl = "http://infra2apps.blob.core.windows.net/eventapp/black-microsoft-logo.jpg";
Name = "Unified Communications & Collaborations";
Sessions = (
{
Description = "Microsoft Lync delivers Unified Communication to help People connect in new ways, anytime, anywhere. Learn how HP and Microsoft are helping customers transform their business infrastrucutre and gain greater productivity by making every communication an interaction that is more collaborative and engaging.";
EndDate = "/Date(1275822000000+0000)/";
FriendlyName = TB3257;
Id = 1;
Location = "Building N-4105";
Speakers = (
{
Company = Microsoft;
Email = "[email protected]";
Name = "John Doe";
Title = "Group Manager";
}
);
StartDate = "/Date(1275818400000+0000)/";
Title = "Connecting People in New Ways with Microsoft Lync";
},
{
Description = "Microsoft Lync delivers Unified Communication to help People connect in new ways, anytime, anywhere. Learn how HP and Microsoft are helping customers transform their business infrastrucutre and gain greater productivity by making every communication an interaction that is more collaborative and engaging.";
EndDate = "/Date(1275825600000+0000)/";
FriendlyName = TB3258;
Id = 2;
Location = "Building N-4105";
Speakers = (
{
Company = HP;
Email = "[email protected]";
Name = "Jane Doe";
Title = "Vice President";
},
{
Company = Microsoft;
Email = "[email protected]";
Name = "John Doe";
Title = "Group Manager";
}
);
StartDate = "/Date(1275822000000+0000)/";
Title = "Connecting People in New Ways with Microsoft Lync - Part 2";
}
);
},
되고 그때 배열에 저장 한 후 그 다른 사전에 콘텐츠 값을 저장한다. 아래 코드는
NSDictionary *boothmenucontents = [json valueForKey: @"Contents"];
NSMutableArray *dictResponseboothmenucontentsArray = [[NSMutableArray alloc] initWithObjects: boothmenucontents,nil];
for(int i = 0; i<[dictResponseboothmenucontentsArray count]; i++)
{
NSMutableArray *IdArrayboothmenucontentes=[[dictResponseboothmenucontentsArray objectAtIndex:i] valueForKey:@"Id"];
NSLog(@"id array is %@",IdArrayboothmenucontentes);
for(int k=0;k<[IdArrayboothmenucontentes count];k++)
{
NSString * strcontentId= [NSString stringWithFormat:@"%@",[IdArrayboothmenucontentes objectAtIndex:k]];
NSLog(@"strcontentId%@",strcontentId);
label.text=strcontentId;
[boothmenuidarrayvalues addObject:strcontentId];
NSLog(@"%@",boothmenuidarrayvalues);
}
}
마침내 내가
가이
"(\n 2,\n 1\n)",
"(\n 4,\n 3\n)",
"(\n 6,\n 5\n)",
"(\n 8,\n 7\n)",
"(\n 10,\n 9\n)",
"(\n 12,\n 11\n)"
처럼 인쇄 boothmenuidarrayvalues를 인쇄
배열 ID를 저장하는 것입니다하지만 난 한 번만 콘텐츠 ID를 인쇄 할하지만로 인쇄 2 번에 1 행. 내가 잘못된 방법을 따르는 경우 해당 응답에 대한 루트를 제공하는 방법을 알려주십시오. 이 줄은 잘못 보이는
IdArrayboothmenucontentes ..를 인쇄 할 수 있습니까? –
@safecase 예 그렇지만 atime에서 두 개의 id 값을 사용합니다. – kumar
다음을 시도해보십시오. NSDictionary * boothmenucontents = [json valueForKey : @ "Contents"]; NSMutableArray * dictResponseboothmenucontentsArray = [[NSMutableArray alloc] initWithObjects : boothmenucontents, nil]; 위한 는 (; 나는 <[dictResponseboothmenucontentsArray 카운트] I = 0 int로 난 ++) {[boothmenuidarrayvalues의 addObject : [dictResponseboothmenucontentsArray objectAtIndex : I] valueForKey : "ID"] @} 그것을 @safecase –