Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-31-2011, 03:48 PM   #1 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default Passing allocated dictionaries through UITableView

Hey all,
I am parsing an RSS feed into a UITableView. In my cellForRoawAtIndex I put all of the parsed data into the cells. After I put them in I do some string manipulation to actually go through and pull out a specific word from the parsed feed. I am trying to store that word in an NSMutableDictionary. I declared my NSMutableDictionary as an ivar. The following code is what I do in the viewDidLoad

Code:
//initialize dictionary 
    myDictionary = [[NSMutableDictionary alloc] initWithCapacity:16];
    myKeys = [NSArray arrayWithObjects:@"test1", @"test2", @"test3", @"test4", @"test5", @"test6", @"test7", @"test8", @"test9", @"test10", @"test11", @"test12", @"test13", @"test14", @"test15", @"test16" ,nil];
    myObjects = [NSArray arrayWithObjects:@"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N",nil];
    myDictionary = [NSMutableDictionary dictionaryWithObject:myObjects forKey:myKeys];
now in my cellForRowAtIndex i have an if statement which pretty much says if the text I'm looking for was found with the rangeOfString method (and then I do the proper methods for that inside the if) now also within the if once I get my specific word, I want to store it in the dictionary and replace the key name in the myKeys array (the key being the word I found, lets just say it was test5) and then switching its corresponding object (in myObjects) "N" to I. See the code below

Code:
 [myDictionary setObject:@"I" forKey:wordKey];
wordKey is a string that contains the word I found. I get an EXC_BAD_ACCESS when I get to that line...

Any help would be appreciated
__________________
Check Out All of Our Apps Here!
iphonig is offline   Reply With Quote
Old 08-02-2011, 10:17 AM   #2 (permalink)
Registered Member
 
iphonig's Avatar
 
Join Date: Sep 2009
Location: United States
Posts: 73
iphonig is on a distinguished road
Default

Quote:
Originally Posted by iphonig View Post
Hey all,
I am parsing an RSS feed into a UITableView. In my cellForRoawAtIndex I put all of the parsed data into the cells. After I put them in I do some string manipulation to actually go through and pull out a specific word from the parsed feed. I am trying to store that word in an NSMutableDictionary. I declared my NSMutableDictionary as an ivar. The following code is what I do in the viewDidLoad

Code:
//initialize dictionary 
    myDictionary = [[NSMutableDictionary alloc] initWithCapacity:16];
    myKeys = [NSArray arrayWithObjects:@"test1", @"test2", @"test3", @"test4", @"test5", @"test6", @"test7", @"test8", @"test9", @"test10", @"test11", @"test12", @"test13", @"test14", @"test15", @"test16" ,nil];
    myObjects = [NSArray arrayWithObjects:@"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N", @"N",nil];
    myDictionary = [NSMutableDictionary dictionaryWithObject:myObjects forKey:myKeys];
now in my cellForRowAtIndex i have an if statement which pretty much says if the text I'm looking for was found with the rangeOfString method (and then I do the proper methods for that inside the if) now also within the if once I get my specific word, I want to store it in the dictionary and replace the key name in the myKeys array (the key being the word I found, lets just say it was test5) and then switching its corresponding object (in myObjects) "N" to I. See the code below

Code:
 [myDictionary setObject:@"I" forKey:wordKey];
wordKey is a string that contains the word I found. I get an EXC_BAD_ACCESS when I get to that line...

Any help would be appreciated
Fixed. I was returning a nil value because NSDictionary performs an autorelease. Just had to set the property to nonatomic, retain and synthesize it
__________________
Check Out All of Our Apps Here!
iphonig is offline   Reply With Quote
Reply

Bookmarks

Tags
exc_bad_access, nsmutablearray, nsmutabledictionary, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 394
15 members and 379 guests
7twenty7, blasterbr, buggen, chiataytuday, dedeys78, dre, fiftysixty, HemiMG, jimmyon122, jonathandeknudt, LEARN2MAKE, nyoe, pungs, tymex, UMAD
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,902
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:02 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0