我有一些信息显示在屏幕上的几个标签上,如时间,按钮坐标,总视频录制时间等。
而不是在标签中显示一些信息?如何使用json文件将这些信息本地保存在内存中?
- (IBAction)firstButton:(UIButton *)sender {
sender.selected = !sender.selected;
[self starting];
[self allButtonsSelected];
_startTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f
target:self
selector:@selector(firtBtnCount)
userInfo:nil
repeats:YES];
self.lblForInfo.text = NSStringFromCGRect(_firstButton.frame);
NSLog(@"STOP RECORDING");
[_startTimer invalidate];
答案 0 :(得分:1)
你可以做到
NSMutableArray *dicArray = [[NSMutableArray alloc]init];
[dicArray addObject:@{@"frame":NSStringFromCGRect(button1.frame)}];
[dicArray addObject:@{@"frame":NSStringFromCGRect(button2.frame)}];
[dicArray addObject:@{@"frame":NSStringFromCGRect(button3.frame)}];
[dicArray addObject:@{@"frame":NSStringFromCGRect(button4.frame)}];
[dicArray addObject:@{@"frame":NSStringFromCGRect(button5.frame)}];
NSLog(@"dicArray:%@",dicArray);
NSData *data = [NSJSONSerialization dataWithJSONObject:dicArray options:kNilOptions error:nil];
NSArray *retDicArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
NSLog(@"retDicArray:%@",retDicArray);