ok so i am doing something kind of unique and need a hand.
I have a plist which is set up like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>B1</key>
<array>
<string>D2</string>
<string>D3</string>
<string>D4</string>
</array>
<key>D2</key>
<array>
<string>F#2</string>
<string>A2</string>
</array>
</dict>
</plist>
with many more arrays in it of course. I am trying to grab the string which i do with this function.
-(NSString *) plistReader:(NSString *)previousNote {
NSDictionary* plist = [ NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"SnowDay" ofType:@"plist"]];//[NSPropertyListSerialization propertyListFromData:plistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&error];
NSArray *possibleNoteList = [plist objectForKey:previousNote];
int randomNumber = [GeneralHelpers randomNumberBetween:0 andMax:[possibleNoteList count]];
NSString *newNote = [NSString stringWithFormat:@"%@%@", [possibleNoteList objectAtIndex:randomNumber], @".mp3"];
lastNotePlayed = [NSString stringWithFormat:@"%@", [possibleNoteList objectAtIndex:randomNumber]];
[lastNotePlayed retain];
return newNote;
}
which works fine and passes the right information back, but because the only way to not have lastNotePlayed (a nsstring that is a variable of the scene) point to a null memory spot is to retain it, it retains the whole nsdictionary which of course causes HORRIBLE leaks.
my question is how can i make a deep copy of the string so that i dont have to worry about the plist and nsdictionary being deallocated
any help would be AMAZING as this is a very key element of my latest project