how to add json parse data in core data in iOS?
This my data parsing code parsing is done.how to add that data in core data
-(void)DataRetireve { deatilinfoarray = [[NSMutableArray alloc] init]; NSURL *url = [NSURL URLWithString: @"http://sms.instatalkcommunications.com/apireq/GetSMSCategories?t=1&h=admin¶m=1"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; }
(void)requestFinished:(ASIHTTPRequest *)request {
NSError *error = [request error]; NSString *responseString = nil;
if (!error) { responseString = [request responseString];
SBJsonParser *parser = [[SBJsonParser alloc] init] ;
NSMutableArray *jsondata = [parser objectWithString:responseString];
NSMutableArray *jsondata1 = [[NSMutableArray alloc]init];
for(int i=0;i<jsondata.count;i++)
{
info *myinfo=[[info alloc]init];
myinfo.Id=@"Id";
myinfo.Name=@"Name";
myinfo.IsActive=@"IsActive";
[jsondata1 addObject:myinfo];
NSLog(@"%@",responseString);
}
for(int i=0;i<jsondata1.count;i++)
{
info *myinfo= [jsondata1 objectAtIndex:i];
[jsondata1 addObject:myinfo];
}
The simplest way you can use it is-
int yPossion = 50, xPossion = 10; int temp = 0;
UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:self.view.frame];
[self.view addSubview:scrollView];
for (int i = 0; i<50; i++){
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeCustom];
[aButton setBackgroundColor:[UIColor blackColor]];
[aButton setBackgroundImage:[UIImage imageNamed:@"icon-menu.png"] forState:UIControlStateNormal];
[aButton setTitle:[NSString stringWithFormat:@" %d",i] forState:UIControlStateNormal];
[aButton setFrame:CGRectMake(xPossion, yPossion, 100, 50)];
[scrollView addSubview:aButton];
xPossion += aButton.frame.size.width+15;
temp++;
if (temp==3) {
yPossion = aButton.frame.origin.y+aButton.frame.size.height+15;
temp = 0;
xPossion = 10;
[scrollView setContentSize:CGSizeMake(scrollView.frame.size.width, yPossion+50)];
}
}
But if you want to it using autoLayout constrains then you can follow this link may be it will help you.
链接地址: http://www.djcxy.com/p/68094.html上一篇: 如何使用队列中的JsonArray