0
votes

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&param=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];
    
        }
    
1
You usually use a UICollectionView in these cases.DeFrenZ
I'd definitely to got Paint Code for something like this. paintcodeapp.com if you're not an addict already. i's the only way to fly - do it once and never do it againFattie

1 Answers

1
votes

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.