iOS 에서 열 거 된 사용법

2316 단어 iOSiosobjectmobilec
	NSLog(@"Hello, World!");
	//     ,key-value
        NSDictionary *myDic=[[NSDictionary alloc]initWithObjectsAndKeys:@"  ",@"name",@"  ",@"name", nil];
        
        NSUInteger count = [myDic count];  
        NSLog(@"      :  %lu",count); 
	//  myDic   key    
        NSEnumerator * myEnumerator = [myDic keyEnumerator];
        for (NSObject *object in myEnumerator) {  
            NSLog(@"  KEY  : %@",object);  
        }
        //  myDic   value     
        myEnumerator = [[myDic allValues] objectEnumerator];
        NSString *value;
        while((value = [myEnumerator nextObject]))
        {
            NSLog(@"    : %@",value);
        }
        
        //  KEY  value  
        NSObject *myObject = [myDic objectForKey:@"name"];
        
        if (myObject != nil) {  
            NSLog(@"  KEY   value : %@",myObject);  
        }  
        
        NSMutableDictionary *mydic2 = [NSMutableDictionary dictionaryWithCapacity:10];  
        [mydic2 setObject:@"Alex Hu" forKey:@"name"];  
        [mydic2 setObject:@"1388888888" forKey:@"mobile number"]; 
        //  mydic2   value     
        for (NSObject *object in [mydic2 objectEnumerator]) {  
            NSLog(@"    : %@",object);  
        }
        
        NSSet *mySet=[NSSet setWithObjects:@"A",@"B",@"C",@"D",[NSNumber numberWithInteger:123], nil];
        count=[mySet count];
        NSLog(@"count= %lu",count);
        //  mySet    
        myEnumerator=[mySet objectEnumerator];
        for (NSObject *object in myEnumerator) {
            NSLog(@"myEnumerator value=%@",object);
            if ([object isEqualTo:@"A"]) {
                NSLog(@"  A ");
            }
            if ([object isEqual:@"B"]) {
                NSLog(@"  B");
            }
        }
        //  mySet NSArray  
        NSArray *mySetArr=[mySet allObjects];
        for (NSUInteger i=0; i%@",i,[mySetArr objectAtIndex:i]);
        }
        
        if ([mySet containsObject:@"D"]) {  
            NSLog(@"      D    ");  
        }  

좋은 웹페이지 즐겨찾기