NSString&NSArray&NSDictionary定义及使用

NSString *greeting=[[NSString alloc] initWithFormat:@"test %@",nameString];
    self.lable.text=greeting;
    NSString *objs[3]={@"one",@"two",@"three"};
    NSArray *dicObj=[NSArray arrayWithObjects:objs count:3];
    NSArray *dicObj2=[[NSArray alloc] initWithObjects:@"one",@"two",@"three", nil];
    NSMutableArray *dicObj3=[NSMutableArray arrayWithCapacity:17];
    for(NSString *obj in dicObj2)
    {
        //if([obj isEqual:@"onew"])
        {
            NSLog(@"good!");
        }
    }
    [dicObj3 enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        if([obj isEqual:@"test"])
        {
            NSLog(@"test here");
            *stop=YES;
        }
    }];
    NSArray *test=[NSArray arrayWithObjects:@"01",@"02", nil];
    NSDictionary *dics=[NSDictionary dictionaryWithObject:test forKey:test];
    NSArray *dkeys=[dics allKeys];
    int count=[dkeys count];
    for(int i=0;i<count;i++)
    {
        id key=[dkeys objectAtIndex:i];
        id value=[dics objectForKey:key];
        NSLog(@"key=%@ value=%@",key,value);
    }
原文地址:https://www.cnblogs.com/wyxy2005/p/2948814.html