Skip to content
Permalink
Browse files

Dealing with some warnings in the Recipes sample

  • Loading branch information...
Coeur committed May 30, 2019
1 parent 366270e commit aca5a64376cfdaee260f33521b8ad55840c0d6f1
@@ -48,7 +48,8 @@ + (NSManagedObjectContext *) MR_contextForCurrentThread;
NSMutableDictionary *threadDict = [[NSThread currentThread] threadDictionary];
NSManagedObjectContext *threadContext = [threadDict objectForKey:kMagicalRecordManagedObjectContextKey];
NSNumber *currentCacheVersionForContext = [threadDict objectForKey:kMagicalRecordManagedObjectContextCacheVersionKey];
NSAssert((threadContext && currentCacheVersionForContext) || (!threadContext && !currentCacheVersionForContext),
NSAssert((threadContext != nil && currentCacheVersionForContext != nil)
|| (threadContext == nil && currentCacheVersionForContext == nil),
@"The Magical Record keys should either both be present or neither be present, otherwise we're in an inconsistent state!");
if ((threadContext == nil) || (currentCacheVersionForContext == nil) || ((int32_t)[currentCacheVersionForContext integerValue] != targetCacheVersionForContext))
{
@@ -61,14 +61,6 @@ - (void)viewDidLoad {
}


- (void)viewDidUnload {
self.instructionsText = nil;
self.nameLabel = nil;

[super viewDidUnload];
}


- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];

@@ -58,7 +58,7 @@ - (void)viewDidLoad {
// Configure the navigation bar
self.navigationItem.title = @"Add Recipe";

UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancel)];
UIBarButtonItem *cancelButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
self.navigationItem.leftBarButtonItem = cancelButtonItem;

UIBarButtonItem *saveButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:@selector(save)];
@@ -68,13 +68,6 @@ - (void)viewDidLoad {
}


- (void)viewDidUnload {
self.nameTextField = nil;

[super viewDidUnload];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Support all orientations except upside-down
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
@@ -168,14 +168,8 @@ - (void)viewWillAppear:(BOOL)animated {
}


- (void)viewDidUnload {
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
self.tableHeaderView = nil;
self.photoButton = nil;
self.nameTextField = nil;
self.overviewTextField = nil;
self.prepTimeTextField = nil;
[super viewDidUnload];
}


@@ -569,7 +563,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
self.recipe.thumbnailImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
}


@@ -99,10 +99,8 @@ - (void)viewDidLoad {
}

// clean up our new observers
- (void)viewDidUnload {
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];

[super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
@@ -67,13 +67,6 @@ - (void)viewDidLoad {
}


- (void)viewDidUnload {
self.tableView = nil;

[super viewDidUnload];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
@@ -76,21 +76,6 @@ - (void)viewDidLoad {
}


- (void)viewDidUnload {
self.pickerViewContainer = nil;

self.metricPickerController = nil;
self.metricPickerViewContainer = nil;

self.imperialPickerController = nil;
self.imperialPickerViewContainer = nil;

self.segmentedControl = nil;

[super viewDidUnload];
}


- (IBAction)toggleUnit {

/*
@@ -19,9 +19,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[MagicalRecord setupCoreDataStackWithStoreNamed:kRecipesStoreName];

// Override point for customization after application launch.
// self.window.backgroundColor = [UIColor whiteColor];
self.recipeListController.managedObjectContext = [NSManagedObjectContext MR_defaultContext];
[self.window addSubview:self.tabBarController.view];
[self.window setRootViewController:self.tabBarController];
[self.window makeKeyAndVisible];
return YES;
}

0 comments on commit aca5a64

Please sign in to comment.
You can’t perform that action at this time.