-
-
- NSString *string = @"hello word";
- NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
- NSArray *array = [NSArray arrayWithObjects:@"1",@"2",@"3",nil];
- NSString *dateString = @"19891123";
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:
- @"hello", @"word",
- @"chen", @"lu",
- @"jin", @"mei",
- @"cerastes", @"hehe",nil];
-
- NSData *string2data = [string dataUsingEncoding:NSUTF8StringEncoding];
- NSLog(@"%@",string2data);
- NSString *data2String = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
- NSLog(@"dataString = %@",data2String);
-
-
- NSData *arry2data = [NSKeyedArchiver archivedDataWithRootObject:array];
- NSArray *data2arry = [NSKeyedUnarchiver unarchiveObjectWithData:arry2data];
- NSLog(@"%@ /n %@",arry2data,data2arry);
-
- NSDate *string2date = [self convertDateFromString:dateString withFormattre:@"yyyyMMdd"];
- NSLog(@"date = %@",string2date);
-
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSString *date2string = [dateFormatter stringFromDate:[NSDate date]];
- NSLog(@"%@", date2string);
-
-
-
-
- NSString *arry2String = [array componentsJoinedByString:@" "];
-
- NSLog(@"string = %@",arry2String);
-
-
- NSArray *string2Arry = [arry2String componentsSeparatedByString:@" "];
- NSLog(@" %@",string2Arry);
-
-
-
- NSMutableData *dic2data = [[NSMutableData alloc] init];
- NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:dic2data];
- [archiver encodeObject:dic forKey:@"Some Key Value"];
- [archiver finishEncoding];
- NSLog(@"%@",dic2data);
-
- NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:dic2data];
- NSDictionary *data2dic = [unarchiver decodeObjectForKey:@"Some Key Value"];
- [unarchiver finishDecoding];
- NSLog(@"%@",data2dic);
-
-
- NSString *dic2string=[dic JSONRepresentation];
- NSLog(@"%@",dic2string);
-
- NSError *error = nil;
- NSDictionary *string2dic = [NSJSONSerialization JSONObjectWithData: [dic2string dataUsingEncoding:NSUTF8StringEncoding]
- options: NSJSONReadingMutableContainers
- error: &error];
- NSLog(@"%@",string2dic);
posted on
2015-02-17 23:51
Stephen_init
阅读(
258)
评论()
编辑
收藏
举报