[英]Objective C TableView Clear Json Parsing
I have working project with manually data but i want to add json parsing in my project. 我有手动数据的工作项目,但我想在项目中添加json解析。 My codes under i think i need help. 我认为我的守则下需要帮助。 ( Must be real time parsing when new item add will be auto release if it possible ) (如果可能的话,必须在新项目添加后自动释放时进行实时解析)
My Table View Codes 我的表格查看代码
- (void)scrollToLastTableViewCell {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.uniqueCodes.count - 1
inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop
animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 15;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellid=@"CustomCell";
CustomTableViewCell *cell=(CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid];;
if(cell==nil)
{
cell=[[CustomTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellid];
}
cell.nameLabel.text=[NSString stringWithFormat:@"This is cell no %d of this table",indexPath.row+1];
cell.cellButton1.tag=101+indexPath.row;
cell.cellButton2.tag=201+indexPath.row;
cell.cellButton3.tag=202+indexPath.row;
cell.cellButton4.tag=203+indexPath.row;
cell.cellButton5.tag=204+indexPath.row;
cell.SwipableUIView.tag=301+indexPath.row;
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
CustomTableViewCell.h CustomTableViewCell.h
@interface CustomTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIView *SwipableUIView;
@property (weak, nonatomic) IBOutlet UIButton *cellButton1;
@property (weak, nonatomic) IBOutlet UIButton *cellButton2;
@property (weak, nonatomic) IBOutlet UIButton *cellButton3;
@property (weak, nonatomic) IBOutlet UIButton *cellButton4;
@property (weak, nonatomic) IBOutlet UIButton *cellButton5;
@property (weak, nonatomic) IBOutlet UIButton *cellButton6;
@property (weak, nonatomic) IBOutlet UIButton *cellButton7;
@end
MY Json 我的杰森
{
"Items": [
{
"name": "My new name 1"
},
{
"name": "My new name 2"
},
{
"name": "My new name 3"
}
]
}
Thanks for everything. 谢谢你所做的一切。
Are you just looking to parse the unique codes out of the JSON, like this: 您是否只是想从JSON中解析出唯一的代码,如下所示:
NSString *jsonString = /* Your JSON String Here */;
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *serializationError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableContainers
error:&serializationError];
NSMutableArray *uniqueCodes = json[@"Items"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.