2016-02-15 28 views
-2

我刚开始使用objective-c开发iOS,并且在习惯语法时遇到了一些麻烦。我提出的目标C注册表单我怎么能存储的字段信息的NSDictionaryObjective-C&NSDictionary

+0

您应该在您的文章中添加一些代码。这将更容易帮助你 –

+0

请参阅:http://hayageek.com/nsdictionary-nsmutabledictionary/ –

+0

请参阅:http://rypress.com/tutorials/objective-c/data-types/nsdictionary –

回答

1

//您已经所有对象

NSString *loginString = @"user1"; 
NSString *passwordString = @"password1"; 
NSDictionary *dict = @{@"login":loginString, @"password":passwordString}; 

//你不必所有对象

NSMutableDictionary *mDict = [NSMutableDictionary new]; 

//When you have loginString you add it to the mDict 

[mDict setObject:@"user2" forKey:@"login"]; 

//When you have passwordString you add it to the mDict 

[mDict setObject:@"password2" forKey:@"password"]; 
0

试此

NSDictionary *[email protected]{@"firstname"  : txtAddFirstName.text, 
        @"lastname"  :txtAddLastName.text, 
        @"region"   :txtRegion.text, 
        @"street"   :txtVAddress.text, 
        @"company"   :txtAddCompny.text, 
        @"city"   :txtCity.text, 
        @"country"   : countryCode, 
        @"postcode"  :txtZip.text, 
        @"telephone"  :txtTelephone.text, 
        @"fax"    :txtFax.text, 
        };