Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check the below code with the necessary changes &amp; answers of your comments.</p> <pre><code>- (void) multitaskingResumeCheck { NSLog(@"Running multitaskingResumeCheck"); // Get the path to the "Documents" directory NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get the path to our plist ("Documents/foo.plist") NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:@"lastStopwatchState.plist"]; // check if our plist already exists in the Documents directory NSMutableDictionary *dict = nil; // Assign the initial value as nil if you're going to assign the actual value later in a conditional block. NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:plistPath]) { // If it does, read it. NSLog(@"dict existed, reading %@", plistPath); dict = [NSMutableDictionary dictionaryWithContentsOfFile:plistPath]; // It's not required to retain as it's being assigned using a class method which in-turn returns an auto-release object. } if (dict) { // Put a conditional check here whether dict is nil or not. // Now check whether the timers were zeroed on exit NSNumber *wrappedATZ = [dict valueForKey:@"allTimersZeroed"]; // No error should come here. BOOL timersWereZeroed = [wrappedATZ boolValue]; // If they were not Zeroed, then we'll load in our data if (!timersWereZeroed) { NSLog(@"Timers were not zeroed. Loading Data."); [self loadResumeData:dict]; } // Dump the contents of the dictionary to the console NSLog(@"dumping..."); for (id key in dict) { NSLog(@"key=%@, value=%@", key, [dict objectForKey:key]); } //[dict release]; No need to release an auto-release object. /** You were executing the below code after releasing the dict object. It might give garbage values which crashes the app. **/ // Dump the contents of the dictionary to the console NSLog(@"dumping..."); for (id key in dict) { NSLog(@"key=%@, value=%@", key, [dict objectForKey:key]); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload