Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7641775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:00:38+00:00 2026-05-31T09:00:38+00:00

i m parsing a json file and populating it in my table view what

  • 0

i m parsing a json file and populating it in my table view what i want to assign is a static row.at the first and last row of my tableview named as Var tycker du. but doing so.it overlaps the dynamically allocated data from json file..could you guys help me out below is the code.

  static NSString * const kCellTextKey = @"CellTextKey";
 static NSString * const kCellStateKey = @"CellStateKey";

 static NSString* kAppId = @"126013844184727";
 #define KFBAccessToken     @"126013844184727"
  #define KFBExpirationDate @"KFBExpirationDate"

  @implementation Tab5

  @synthesize tableview1,jsonData,jsonArray,story,media1,url,descriptiondesc,media2;
  @synthesize arForIPs = _arForIPs;
  - (void)viewDidLoad {
   [super viewDidLoad];
objMan = [[HJObjManager alloc] initWithLoadingBufferSize:6 memCacheSize:20];
self.arForIPs=[NSMutableArray array];


    self.tableview1.backgroundColor=[UIColor clearColor];
[self.tableview1 setAllowsSelectionDuringEditing:TRUE];

jsonurl=[NSURL URLWithString:@"http://dev-parkguiden.knutpunkten.se/Api/GetPark? parkid=3"];
NSURLRequest *request = [NSURLRequest requestWithURL:jsonurl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
connection1=[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];

self.jsonData=[NSData dataWithContentsOfURL:jsonurl];

NSDictionary *items=[NSJSONSerialization JSONObjectWithData:self.jsonData options:NSJSONReadingMutableLeaves error:nil];

items1 = [items objectForKey:@"ThingsTodo"];

story = [[NSMutableArray array]retain];
media1 = [[NSMutableArray array]retain];

url=[[NSMutableArray array]retain];
media2=[[NSMutableArray array]retain];
descriptiondesc=[[NSMutableArray array]retain];
dog=[[NSMutableArray array]retain];
arr=[[NSMutableArray array]retain];
bose=[[NSMutableArray array]retain];
for (NSDictionary *item in items1)
{
    [self.story addObject:[item objectForKey:@"Name"]];
    [self.media1 addObject:[item objectForKey:@"Status"]];
    //[self.media2 addObject:[item objectForKey:@"Image"]];

}

//NSLog(@"room:%@",items1);
[self makeNewArray];


    }


    -(void)makeNewArray
     {
   for ( int i=0; i<[self.media1 count]; i++) 
    {

    NSDictionary *boy=[self.media1 objectAtIndex:i];



    NSString *str=[[NSString alloc]initWithFormat:@"%@",boy];
    //NSLog(@"the value:%@",str);

    if([str isEqualToString:@"1"])
    { 
        text = [self.story objectAtIndex:i];
        NSString *text1 = [NSString stringWithFormat:@"%@",text];
        NSNumber *state = [NSNumber numberWithBool:NO];


     dict=[NSDictionary dictionaryWithObjectsAndKeys:text1,kCellTextKey,state,kCellStateKey,nil];
       [arr addObject:dict];



  //  [dog addObject:[self.story objectAtIndex:i]];


    }
    dog=[arr mutableCopy];
      NSLog(@"wat hav i got:%@",arr);  

     }

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{

return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

 {

return [dog count];

 }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];    }
 // cell.textLabel.text=[dog objectAtIndex:indexPath.row];
NSDictionary *rowData = [dog objectAtIndex:indexPath.row];
cell.textLabel.text = [rowData objectForKey:kCellTextKey];
if ([[rowData objectForKey:kCellStateKey] boolValue]) {
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
    cell.accessoryType = UITableViewCellAccessoryNone;
    [bose removeObject:[newDict valueForKey:@"CellTextKey"]];
   // NSLog(@"object going to get removed:%@",bose);
}
sectionRows = [tableview1 numberOfRowsInSection:[indexPath section]];



return cell;

  }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath   *)indexPath {
NSDictionary *dict = [dog objectAtIndex:indexPath.row];
BOOL newState = ![[dict objectForKey:kCellStateKey] boolValue];
newDict = [NSDictionary dictionaryWithObjectsAndKeys:[dict objectForKey:kCellTextKey],    kCellTextKey, [NSNumber numberWithBool:newState], kCellStateKey, nil];
[dog replaceObjectAtIndex:indexPath.row withObject:newDict];

[bose addObject:[newDict valueForKey:@"CellTextKey"]];
 NSLog(@"the current added data:%@",bose);
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];

   }
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:00:40+00:00Added an answer on May 31, 2026 at 9:00 am

    hey try out with this solution

    -(void)makeNewArray
    {
    for ( int i=0; i<[self.media1 count]; i++) 
    {
    
        NSDictionary *boy=[self.media1 objectAtIndex:i];
        NSString *str=[[NSString alloc]initWithFormat:@"%@",boy];
        //NSLog(@"the value:%@",str);
    
        if([str isEqualToString:@"1"])
        { 
            text = [self.story objectAtIndex:i];
            NSString *text1 = [NSString stringWithFormat:@"%@",text];
            NSNumber *state = [NSNumber numberWithBool:NO];
    
    
            dict=[NSDictionary dictionaryWithObjectsAndKeys:text1,kCellTextKey,state,kCellStateKey,nil];
            [arr addObject:dict];
    
            //  [dog addObject:[self.story objectAtIndex:i]];
        }
    }
    NSDictionary *dict;
    
    dict = [NSDictionary dictionaryWithObjectsAndKeys:
            @"Var tycker du", @"CellTextKey", 
            @"0", @"CellStateKey", nil];
    [dog addObject:dict];
    for(int i=0; i<arr.count; i++){
        [dog addObject:[arr objectAtIndex:i]];
    }
    
    
    [dog addObject:dict];        
    //        dog=[arr mutableCopy];
    NSLog(@"wat hav i got:%@",dog);  
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing a JSON file which contains a timestamp. I want to convert
I am parsing data from a json file and converting to a HTML table,
I'm having a problem parsing a JSON file in AS3. Im trying to parse
I am parsing a JSON file. After getting the NSDictionary, I parse the objects
i'm parsing a json file in an unordered list. the problem is that i
I have an XML file which I want to convert into JSON file using
I need to create a dynamic html table using PHP after parsing a JSON
I'm parsing a JSON file that I'm retrieving by accessing an API. Right now,
I'm new to XML parsing and want to convert XML file resulting from a
I have this JSON file (the parsing OK, the problem is displaying the contents

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.