NSArray
NSArray *ArrSingle = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
NSLog(@"Show Array Single: %@",ArrSingle);
OUTPUT :
Show Array Single: (
1,
2,
3,
4,
5
)
NSArray *ArrDimension;
ArrDimension = [[NSArray alloc] initWithObjects:
[[NSArray alloc] initWithObjects: @"1.1", @"1.2", @"1.3", @"1.4", @"1.5", nil],
[[NSArray alloc] initWithObjects: @"2.1", @"2.2", @"2.3", @"2.4", @"2.5", nil],nil ];
NSLog(@"Show data Array Dimension: %@",ArrDimension);
OUTPUT:
Show data Array Dimension: (
(
"1.1",
"1.2",
"1.3",
"1.4",
"1.5"
),
(
"2.1",
"2.2",
"2.3",
"2.4",
"2.5"
)
)
NSLog(@"Show data Array Dimension base on index: %@",ArrDimension[1]);
OR
NSLog(@"Show data Array Dimension base on index: %@",[ArrDimension objectAtIndex:1]);
OUTPUT:
Show data Array Dimension base on index: (
"2.1",
"2.2",
"2.3",
"2.4",
"2.5"
)
NSMutableArray
NSMutableArray *myColors = [[NSMutableArray alloc] init];
Set array null
NSMutableArray *myColors = [NSMutableArray arrayWithObjects: nil];
Inserts a given object at the end of the array :
[myColors addObject: @“blue”];
[myColors addObject: @“black”];
[myColors addObject: @“yellow”];
then green in index 0 and yellow in index 2
NSLog(@"Show data Array: %@",myColors);
OUTPUT:
Show Array color: (
blue,
black,
yellow
)
NSLog(@"Show data Array at index 1: %@",myColors[2]);
OUTPUT:
Show data Array at index 1: yellow
NSArray *arrSecond = [NSArray arrayWithObjects:@"One",@"Two",@"Three",nil];
NSMutableArray *arrData = [NSMutableArray arrayWithObjects:@"Four",@"Five",@"Six",nil];
Marge two array
[arrData addObjectsFromArray:arrSecond];
NSLog(@"Show Array arrData marge arrSecond: %@",arrData);
OUTPUT:
Show Array arrData marge arrSecond: (
Four,
Five,
Six,
One,
Two,
Three
)
add 1 object to arrData
[arrData addObject:@"seven"];
NSLog(@"Show Array arrData after add object: %@",arrData);
OUTPUT:
Show Array arrData after add object: (
Four,
Five,
Six,
One,
Two,
Three,
seven
)
NSMutableDictionary
NSMutableDictionary *myDictionary = [[ NSMutableDictionary alloc] init];
[ myDictionary setObject:@"Luter" forKey:@"name"];
[ myDictionary setObject:@"IOS Developer" forKey:@"position"];
[ myDictionary setObject:@"08/12/1984" forKey:@"born"];
NSLog(@"Show Array myDictionary: %@",myDictionary);
OUTPUT:
Show Array myDictionary: {
born = "08/12/1984";
name = Luter;
position = "IOS Developer";
}
NSArray *arrNS = [NSArray arrayWithObjects:@"objective c",@"PHP",@"JavaScript",nil];
NSMutableArray *arrMutable = [NSMutableArray arrayWithObjects:@"swimming”,@“footbal",@"badminton",nil];
Set object NSArray and NSMutableArray to NSMutableDictionary
[ myDictionary setObject:arrNS forKey:@"skill"];
[ myDictionary setObject:arrMutable forKey:@"skill"];
NSLog(@"Show Array myDictionary SET object: %@",myDictionary);
OUTPUT:
Show Array arrData after add object: {
born = "08/12/1984";
name = Luter;
position = "IOS Developer";
hobby = (
swimming,
footbal,
badminton
);
skill = (
"objective c",
PHP,
JavaScript
);
}

This comment has been removed by the author.
ReplyDelete