Revision: 59740
Updated Code
at January 3, 2013 07:31 by kutyadog
Updated Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray]; NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; [TempShortArray setArray:[[xTempArray objectAtIndex:i] componentsSeparatedByString:@","] ]; //------------------------NSArray //from http://www.icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/ // I am using strings, but you can add just about any object to an NSArray // Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Don't forget to add nil as the last object NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; // Creates an NSArray from another NSArray NSArray * myArray3 = [NSArray arrayWithArray:myArray2]; // This will create an NSArray from data on iCodeBlog. Go ahead and try it out, this file exists on our servers and contains valid data. NSArray * myArray4 = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://icodeblog.com/wp-content/uploads/2009/08/foo.plist"]]; NSString * f = @"foo"; NSString * b = @"bar"; NSString * z = @"baz"; NSArray * myArray2 = [NSArray arrayWithObjects:f,b,z,nil]; NSInteger idx = [myArray2 indexOfObject:b]; // This would return 1 (since NSArrays are 0 - indexed) // Lets pretend the bullet object has a method called move // and there is an array of 50 bullets [bullets makeObjectsPerformSelector:@selector(move)]; NSArray *sortedArray = [myArray2 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; // This will return a sorted array that looks like [@"bar",@"baz",@"foo"] for(NSString * myStr in myArray2) { NSLog(myStr); } //save data to file NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; [myArray2 writeToFile:filePath atomically:YES]; //http://www.techotopia.com/index.php/Working_with_Objective-C_Array_Objects //--NSArray can not be changed! NSArray *myColors; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //requires the nil at end NSLog (@"Number of elements in array = %lu", [myColors count]); //NSMutableArray CAN be changed NSMutableArray *myColors; myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //------- NSArray *myColors; int i; int count; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; count = [myColors count]; for (i = 0; i < count; i++) NSLog (@"Element %i = %@", i, [myColors objectAtIndex: i]); //------- NSArray *myColors; NSString *color; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; for (color in myColors) NSLog (@"Element = %@", color); //adding [myColors addObject: @"Indigo"]; [myColors addObject: @"Violet"]; //inserting [myColors insertObject: @"Indigo" atIndex: 1]; [myColors insertObject: @"Violet" atIndex: 3]; //deleting [myColors removeObjectAtIndex: 0]; [myColors removeObject: @"Red"]; [myColors removeObjectIdenticalTo: @"Red"]; [myColors removeAllObjects]; [myColors removeLastObject]; //sorting NSArray *sortedArray; sortedArray = [myColors sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; //----------DICTIONARY OBJECTS //Once a relationship between a key and a value has been established that relationship cannot subsequently be modified. //creating: NSDictionary *bookListing = [NSDictionary dictionary]; //or changeble NSMutableDictionary *bookListing = [NSMutableDictionary dictionary]; //populating [bookListing setObject: @"Wind in the Willows" forKey: @"100-432112"]; [bookListing setObject: @"Tale of Two Cities " forKey: @"200-532874"]; [bookListing setObject: @"Sense and Sensibility" forKey: @"202-546549"]; [bookListing setObject: @"Shutter Island" forKey: @"104-109834"]; //or NSDictionary *bookListing = [NSDictionary dictionaryWithObjectsAndKeys: @"Wind in the Willows", @"100-432112", @"Tale of Two Cities ", @"200-532874", @"Sense and Sensibility", @"202-546549", @"Shutter Island", @"104-109834", nil]; //or NSArray *objectsArray = [NSArray arrayWithObjects: @"Wind in the Willows", @"Tale of Two Cities ", @"Sense and Sensibility", @"Shutter Island", nil]; NSArray *keysArray = [NSArray arrayWithObjects: @"100-432112", @"200-532874", @"202-546549", @"104-109834", nil]; NSDictionary *bookListing = [[NSDictionary alloc] initWithObjects: objectsArray forKeys: keysArray]; //------get an entry count NSMutableDictionary *bookListing = [NSMutableDictionary dictionary]; int count; [bookListing setObject: @"Wind in the Willows" forKey: @"100-432112"]; [bookListing setObject: @"Tale of Two Cities " forKey: @"200-532874"]; [bookListing setObject: @"Sense and Sensibility" forKey: @"202-546549"]; [bookListing setObject: @"Shutter Island" forKey: @"104-109834"]; NSLog (@"Number of books in dictionary = %lu", [bookListing count]); //calling the data: NSLog ( @"100-432112 = %@", [bookListing objectForKey: @"100-432112"]); NSLog ( @"200-532874 = %@", [bookListing objectForKey: @"200-532874"]); NSLog ( @"202-546549 = %@", [bookListing objectForKey: @"202-546549"]); NSLog ( @"104-109834 = %@", [bookListing objectForKey: @"104-109834"]); //deleting [bookListing removeObjectForKey: @"104-109834"]; [bookListing removeAllObjects]; //---------use blocks to go through each item of array NSArray *cards = [NSArray arrayWithObjects:@"Jack", @"Queen", @"King", @"Ace", nil]; [cards enumerateObjectsUsingBlock:^(id object, NSUInteger index, BOOL *stop) { NSLog(@"%@ card at index %d", object, index); }]; //--------array of ints [NSArray arrayWithObjects:[ NSNumber numberWithInteger: 1500 ],[ NSNumber numberWithInteger: 1750 ],nil] //--------accessing array object as int [[xArray objectAtIndex:x] intValue];
Revision: 59739
Updated Code
at October 26, 2012 07:30 by kutyadog
Updated Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray]; NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; [TempShortArray setArray:[[xTempArray objectAtIndex:i] componentsSeparatedByString:@","] ]; //------------------------NSArray //from http://www.icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/ // I am using strings, but you can add just about any object to an NSArray // Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Don't forget to add nil as the last object NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; // Creates an NSArray from another NSArray NSArray * myArray3 = [NSArray arrayWithArray:myArray2]; // This will create an NSArray from data on iCodeBlog. Go ahead and try it out, this file exists on our servers and contains valid data. NSArray * myArray4 = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://icodeblog.com/wp-content/uploads/2009/08/foo.plist"]]; NSString * f = @"foo"; NSString * b = @"bar"; NSString * z = @"baz"; NSArray * myArray2 = [NSArray arrayWithObjects:f,b,z,nil]; NSInteger idx = [myArray2 indexOfObject:b]; // This would return 1 (since NSArrays are 0 - indexed) // Lets pretend the bullet object has a method called move // and there is an array of 50 bullets [bullets makeObjectsPerformSelector:@selector(move)]; NSArray *sortedArray = [myArray2 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; // This will return a sorted array that looks like [@"bar",@"baz",@"foo"] for(NSString * myStr in myArray2) { NSLog(myStr); } //save data to file NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; [myArray2 writeToFile:filePath atomically:YES]; //http://www.techotopia.com/index.php/Working_with_Objective-C_Array_Objects //--NSArray can not be changed! NSArray *myColors; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //requires the nil at end NSLog (@"Number of elements in array = %lu", [myColors count]); //NSMutableArray CAN be changed NSMutableArray *myColors; myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //------- NSArray *myColors; int i; int count; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; count = [myColors count]; for (i = 0; i < count; i++) NSLog (@"Element %i = %@", i, [myColors objectAtIndex: i]); //------- NSArray *myColors; NSString *color; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; for (color in myColors) NSLog (@"Element = %@", color); //adding [myColors addObject: @"Indigo"]; [myColors addObject: @"Violet"]; //inserting [myColors insertObject: @"Indigo" atIndex: 1]; [myColors insertObject: @"Violet" atIndex: 3]; //deleting [myColors removeObjectAtIndex: 0]; [myColors removeObject: @"Red"]; [myColors removeObjectIdenticalTo: @"Red"]; [myColors removeAllObjects]; [myColors removeLastObject]; //sorting NSArray *sortedArray; sortedArray = [myColors sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; //----------DICTIONARY OBJECTS //Once a relationship between a key and a value has been established that relationship cannot subsequently be modified. //creating: NSDictionary *bookListing = [NSDictionary dictionary]; //or changeble NSMutableDictionary *bookListing = [NSMutableDictionary dictionary]; //populating [bookListing setObject: @"Wind in the Willows" forKey: @"100-432112"]; [bookListing setObject: @"Tale of Two Cities " forKey: @"200-532874"]; [bookListing setObject: @"Sense and Sensibility" forKey: @"202-546549"]; [bookListing setObject: @"Shutter Island" forKey: @"104-109834"]; //or NSDictionary *bookListing = [NSDictionary dictionaryWithObjectsAndKeys: @"Wind in the Willows", @"100-432112", @"Tale of Two Cities ", @"200-532874", @"Sense and Sensibility", @"202-546549", @"Shutter Island", @"104-109834", nil]; //or NSArray *objectsArray = [NSArray arrayWithObjects: @"Wind in the Willows", @"Tale of Two Cities ", @"Sense and Sensibility", @"Shutter Island", nil]; NSArray *keysArray = [NSArray arrayWithObjects: @"100-432112", @"200-532874", @"202-546549", @"104-109834", nil]; NSDictionary *bookListing = [[NSDictionary alloc] initWithObjects: objectsArray forKeys: keysArray]; //------get an entry count NSMutableDictionary *bookListing = [NSMutableDictionary dictionary]; int count; [bookListing setObject: @"Wind in the Willows" forKey: @"100-432112"]; [bookListing setObject: @"Tale of Two Cities " forKey: @"200-532874"]; [bookListing setObject: @"Sense and Sensibility" forKey: @"202-546549"]; [bookListing setObject: @"Shutter Island" forKey: @"104-109834"]; NSLog (@"Number of books in dictionary = %lu", [bookListing count]); //calling the data: NSLog ( @"100-432112 = %@", [bookListing objectForKey: @"100-432112"]); NSLog ( @"200-532874 = %@", [bookListing objectForKey: @"200-532874"]); NSLog ( @"202-546549 = %@", [bookListing objectForKey: @"202-546549"]); NSLog ( @"104-109834 = %@", [bookListing objectForKey: @"104-109834"]); //deleting [bookListing removeObjectForKey: @"104-109834"]; [bookListing removeAllObjects]; //---------use blocks to go through each item of array NSArray *cards = [NSArray arrayWithObjects:@"Jack", @"Queen", @"King", @"Ace", nil]; [cards enumerateObjectsUsingBlock:^(id object, NSUInteger index, BOOL *stop) { NSLog(@"%@ card at index %d", object, index); }];
Revision: 59738
Updated Code
at September 29, 2012 08:15 by kutyadog
Updated Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray]; NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; [TempShortArray setArray:[[xTempArray objectAtIndex:i] componentsSeparatedByString:@","] ]; //------------------------NSArray //from http://www.icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/ // I am using strings, but you can add just about any object to an NSArray // Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Don't forget to add nil as the last object NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; // Creates an NSArray from another NSArray NSArray * myArray3 = [NSArray arrayWithArray:myArray2]; // This will create an NSArray from data on iCodeBlog. Go ahead and try it out, this file exists on our servers and contains valid data. NSArray * myArray4 = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://icodeblog.com/wp-content/uploads/2009/08/foo.plist"]]; NSString * f = @"foo"; NSString * b = @"bar"; NSString * z = @"baz"; NSArray * myArray2 = [NSArray arrayWithObjects:f,b,z,nil]; NSInteger idx = [myArray2 indexOfObject:b]; // This would return 1 (since NSArrays are 0 - indexed) // Lets pretend the bullet object has a method called move // and there is an array of 50 bullets [bullets makeObjectsPerformSelector:@selector(move)]; NSArray *sortedArray = [myArray2 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; // This will return a sorted array that looks like [@"bar",@"baz",@"foo"] for(NSString * myStr in myArray2) { NSLog(myStr); } //save data to file NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; [myArray2 writeToFile:filePath atomically:YES]; //http://www.techotopia.com/index.php/Working_with_Objective-C_Array_Objects //--NSArray can not be changed! NSArray *myColors; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //requires the nil at end NSLog (@"Number of elements in array = %lu", [myColors count]); //NSMutableArray CAN be changed NSMutableArray *myColors; myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //------- NSArray *myColors; int i; int count; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; count = [myColors count]; for (i = 0; i < count; i++) NSLog (@"Element %i = %@", i, [myColors objectAtIndex: i]); //------- NSArray *myColors; NSString *color; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; for (color in myColors) NSLog (@"Element = %@", color); //adding [myColors addObject: @"Indigo"]; [myColors addObject: @"Violet"]; //inserting [myColors insertObject: @"Indigo" atIndex: 1]; [myColors insertObject: @"Violet" atIndex: 3]; //deleting [myColors removeObjectAtIndex: 0]; [myColors removeObject: @"Red"]; [myColors removeObjectIdenticalTo: @"Red"]; [myColors removeAllObjects]; [myColors removeLastObject]; //sorting NSArray *sortedArray; sortedArray = [myColors sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; //----------DICTIONARY OBJECTS //Once a relationship between a key and a value has been established that relationship cannot subsequently be modified. //creating: NSDictionary *bookListing = [NSDictionary dictionary]; //or changeble NSMutableDictionary *bookListing = [NSMutableDictionary dictionary]; //populating [bookListing setObject: @"Wind in the Willows" forKey: @"100-432112"]; [bookListing setObject: @"Tale of Two Cities " forKey: @"200-532874"]; [bookListing setObject: @"Sense and Sensibility" forKey: @"202-546549"]; [bookListing setObject: @"Shutter Island" forKey: @"104-109834"]; //or NSDictionary *bookListing = [NSDictionary dictionaryWithObjectsAndKeys: @"Wind in the Willows", @"100-432112", @"Tale of Two Cities ", @"200-532874", @"Sense and Sensibility", @"202-546549", @"Shutter Island", @"104-109834", nil]; //or NSArray *objectsArray = [NSArray arrayWithObjects: @"Wind in the Willows", @"Tale of Two Cities ", @"Sense and Sensibility", @"Shutter Island", nil]; NSArray *keysArray = [NSArray arrayWithObjects: @"100-432112", @"200-532874", @"202-546549", @"104-109834", nil]; NSDictionary *bookListing = [[NSDictionary alloc] initWithObjects: objectsArray forKeys: keysArray]; //------get an entry count NSMutableDictionary *bookListing = [NSMutableDictionary dictionary]; int count; [bookListing setObject: @"Wind in the Willows" forKey: @"100-432112"]; [bookListing setObject: @"Tale of Two Cities " forKey: @"200-532874"]; [bookListing setObject: @"Sense and Sensibility" forKey: @"202-546549"]; [bookListing setObject: @"Shutter Island" forKey: @"104-109834"]; NSLog (@"Number of books in dictionary = %lu", [bookListing count]); //calling the data: NSLog ( @"100-432112 = %@", [bookListing objectForKey: @"100-432112"]); NSLog ( @"200-532874 = %@", [bookListing objectForKey: @"200-532874"]); NSLog ( @"202-546549 = %@", [bookListing objectForKey: @"202-546549"]); NSLog ( @"104-109834 = %@", [bookListing objectForKey: @"104-109834"]); //deleting [bookListing removeObjectForKey: @"104-109834"]; [bookListing removeAllObjects];
Revision: 59737
Updated Code
at September 29, 2012 08:06 by kutyadog
Updated Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray]; NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; [TempShortArray setArray:[[xTempArray objectAtIndex:i] componentsSeparatedByString:@","] ]; //------------------------NSArray //from http://www.icodeblog.com/2009/08/26/objective-c-tutorial-nsarray/ // I am using strings, but you can add just about any object to an NSArray // Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Don't forget to add nil as the last object NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; // Creates an NSArray from another NSArray NSArray * myArray3 = [NSArray arrayWithArray:myArray2]; // This will create an NSArray from data on iCodeBlog. Go ahead and try it out, this file exists on our servers and contains valid data. NSArray * myArray4 = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://icodeblog.com/wp-content/uploads/2009/08/foo.plist"]]; NSString * f = @"foo"; NSString * b = @"bar"; NSString * z = @"baz"; NSArray * myArray2 = [NSArray arrayWithObjects:f,b,z,nil]; NSInteger idx = [myArray2 indexOfObject:b]; // This would return 1 (since NSArrays are 0 - indexed) // Lets pretend the bullet object has a method called move // and there is an array of 50 bullets [bullets makeObjectsPerformSelector:@selector(move)]; NSArray *sortedArray = [myArray2 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; // This will return a sorted array that looks like [@"bar",@"baz",@"foo"] for(NSString * myStr in myArray2) { NSLog(myStr); } //save data to file NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; [myArray2 writeToFile:filePath atomically:YES]; //http://www.techotopia.com/index.php/Working_with_Objective-C_Array_Objects //--NSArray can not be changed! NSArray *myColors; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //requires the nil at end NSLog (@"Number of elements in array = %lu", [myColors count]); //NSMutableArray CAN be changed NSMutableArray *myColors; myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; //------- NSArray *myColors; int i; int count; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; count = [myColors count]; for (i = 0; i < count; i++) NSLog (@"Element %i = %@", i, [myColors objectAtIndex: i]); //------- NSArray *myColors; NSString *color; myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; for (color in myColors) NSLog (@"Element = %@", color); //adding [myColors addObject: @"Indigo"]; [myColors addObject: @"Violet"]; //inserting [myColors insertObject: @"Indigo" atIndex: 1]; [myColors insertObject: @"Violet" atIndex: 3]; //deleting [myColors removeObjectAtIndex: 0]; [myColors removeObject: @"Red"]; [myColors removeObjectIdenticalTo: @"Red"]; [myColors removeAllObjects]; [myColors removeLastObject];
Revision: 59736
Updated Code
at September 29, 2012 07:55 by kutyadog
Updated Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray]; NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; [TempShortArray setArray:[[xTempArray objectAtIndex:i] componentsSeparatedByString:@","] ]; //------------------------NSArray // I am using strings, but you can add just about any object to an NSArray // Creates an NSArray with one object NSArray * myArray = [NSArray arrayWithObject:@"foo"]; // Creates an NSArray with multiple objects. Don't forget to add nil as the last object NSArray * myArray2 = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil]; // Creates an NSArray from another NSArray NSArray * myArray3 = [NSArray arrayWithArray:myArray2]; // This will create an NSArray from data on iCodeBlog. Go ahead and try it out, this file exists on our servers and contains valid data. NSArray * myArray4 = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:@"http://icodeblog.com/wp-content/uploads/2009/08/foo.plist"]];
Revision: 59735
Updated Code
at September 29, 2012 07:51 by kutyadog
Updated Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray]; NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; [TempShortArray setArray:[[xTempArray objectAtIndex:i] componentsSeparatedByString:@","] ];
Revision: 59734
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 27, 2012 02:39 by kutyadog
Initial Code
[selectedLevels replaceObjectAtIndex:0 withObject:3]; NSLog(@"Count: %i, %@", 0, [selectedLevels objectAtIndex:0]); NSMutableArray *TempShortArray = [[NSMutableArray alloc] init]; NSLog(@"Count: %i, %@", i, [xTempArray objectAtIndex:i]); NSLog(@"Count: %i", [xTempArray count]); gameData[0].stars = 2; ScoreAndLevelData = [[NSMutableArray alloc] initWithCapacity:10]; [ScoreAndLevelData addObject:TempShortArray];
Initial URL
Initial Description
Examples of different things you can do with arrays
Initial Title
xCode Objective C Array examples
Initial Tags
Initial Language
Objective C