viewcontroller.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property NSMutableArray *array1,*array2,*array3;
@end
viewcontroller.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//methods
self.array1=[[NSMutableArray alloc]initWithObjects:@"naresh",@"naidu",@"kolindala", nil];
NSLog(@"%@",self.array1);
NSLog(@"%lu",self.array1.count);
NSLog(@"%@",[self.array1 objectAtIndex:1]);
NSLog(@"%@",[self.array1 arrayByAddingObject:@"nk"]);
NSLog(@"%@",[self.array1 arrayByAddingObjectsFromArray:self.array2]);
self.array2=[[NSMutableArray alloc]initWithObjects:@"jack", nil];
// NSMutableArray *mmm = [NSMutableArray arrayWithCapacity: 20];
// NSMutableArray *kkk = [NSMutableArray arrayWithObjects: @"a", @"b", @"cat", @"dog", nil];
//
// [mmm addObjectsFromArray:kkk];
//
// NSLog(@"Working: %@",[mmm objectAtIndex:3]);
[self.array1 addObjectsFromArray:self.array2];
NSLog(@"Working: %@",[self.array1 objectAtIndex:3]);
NSLog(@"%@",[self.array1 componentsJoinedByString:@" / "]);
// NSArray *collection = [[NSArray alloc] initWithObjects:A, B, C, nil]; //A, B, C are custom "Item" objects
// Item *tempItem = [[Item alloc] initWithLength:1 width:2 height:3]; //3 instance variables in "Item" objects
// if([collection containsObject:tempItem]) {
// NSLog(@"collection contains this item");
// }
if ([self.array1 containsObject:self.array2]) {
NSLog(@"all objects");
}else{
NSLog(@"no objects");
}
NSString *jobName = [NSString stringWithFormat:@"john"];
[self.array2 addObject:jobName];
NSLog(@"%@",self.array2);
[self.array2 insertObject:self.array1 atIndex:0];
NSLog(@"%@",self.array2);
[self.array1 removeLastObject];
NSLog(@"%@",self.array1);
[self.array2 removeObjectAtIndex:1];
NSLog(@"%@",self.array2);
[self.array2 replaceObjectAtIndex:0 withObject:@"cena"];
NSLog(@"%@",self.array2);
self.array3=[[NSMutableArray alloc]initWithObjects:@"naresh",@"naidu",@"kolindala", nil];
NSArray *theData = [NSArray arrayWithObjects:@"One",@"Two",@"Three",nil];
NSMutableArray *mut = [NSMutableArray arrayWithObjects:@"Four",@"Five",@"Six",nil];
[mut addObjectsFromArray:theData];
NSLog(@"%@",mut);
NSLog(@"%@",[mut class]);
[mut addObject:@"seven"];
NSLog(@"%@",mut);
//initwithcapacity
// int index=0;
//
// NSMutableArray * array = [[NSMutableArray alloc] initWithCapacity:4]; //in viewDidLoad
//
// if (index == 0){
// [array insertObject:@"nani" atIndex:0];
// }
//
// if (index == 1){
// [array insertObject:@"naresh" atIndex:1];
// }
//
// if (index == 2){
// [array insertObject:@"naidu" atIndex:2];
// }
//
// if (index == 3){
// [array insertObject:@"kolindala" atIndex:3];
// }
//
// NSLog(@"array = %i",index);
//
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up here with your email
ConversionConversion EmoticonEmoticon