01.
02.
03.
04.
NSDictionary
*dict;
05.
06.
NSMutableArray
*myObject;
07.
08.
09.
NSString
*memberid;
10.
NSString
*name;
11.
NSString
*tel;
12.
13.
14.
memberid = @
"MemberID"
;
15.
name = @
"Name"
;
16.
tel = @
"Tel"
;
17.
18.
19.
20.
myObject = [[
NSMutableArray
alloc] init];
21.
22.
dict = [
NSDictionary
dictionaryWithObjectsAndKeys:
23.
@
"1"
, memberid,
24.
@
"Weerachai"
, name,
25.
@
"0819876107"
, tel,
26.
nil
];
27.
[myObject addObject:dict];
28.
29.
30.
dict = [
NSDictionary
dictionaryWithObjectsAndKeys:
31.
@
"2"
, memberid,
32.
@
"Win"
, name,
33.
@
"021978032"
, tel,
34.
nil
];
35.
[myObject addObject:dict];
36.
37.
38.
dict = [
NSDictionary
dictionaryWithObjectsAndKeys:
39.
@
"3"
, memberid,
40.
@
"Eak"
, name,
41.
@
"087654321"
, tel,
42.
nil
];
43.
[myObject addObject:dict];
44.
45.
NSData
*jsonData = [
NSJSONSerialization
dataWithJSONObject:myObject
46.
options:
NSJSONWritingPrettyPrinted
47.
error:
nil
];
48.
49.
50.
51.
52.
53.
54.
id
jsonObjects = [
NSJSONSerialization
JSONObjectWithData:jsonData options:
NSJSONReadingMutableContainers
error:
nil
];
55.
56.
57.
for
(
NSDictionary
*dataDict in jsonObjects) {
58.
NSString
*strMemberID = [dataDict objectForKey:@
"MemberID"
];
59.
NSString
*strName = [dataDict objectForKey:@
"Name"
];
60.
NSString
*strTel = [dataDict objectForKey:@
"Tel"
];
61.
NSLog
(@
"MemberID = %@"
,strMemberID);
62.
NSLog
(@
"Name = %@"
,strName);
63.
NSLog
(@
"Tel = %@"
,strTel);
64.
65.
NSLog
(@
"===================="
);
66.
}