dealloc

RestKit Core Data NSError dealloc Crash

拈花ヽ惹草 提交于 2019-11-30 23:17:36
Trying to get to the bottom of an issue I've been seeing in production builds and FINALLY was able to reproduce it while testing. Using RestKit v0.23.1, when doing an RKManagedObjectRequestOperation using the following code (while plugged into instruments) I get "An Objective-C message was sent to a deallocated 'NSError' object (zombie)" and the app crashes every time there's objects in the response JSON - if the response is something like "objects = ();" there's no crash - so I'm guessing it's somewhere in the RestKit/Core Data mapping or storage? RKManagedObjectRequestOperation

SKScene Fails to deallocate memory resulting in bounded memory growth

半腔热情 提交于 2019-11-30 17:02:12
问题 I have been struggling with this for days, for some reason my SKScenes are not deallocating correctly, this results in bounded memory growth as each time i exit and enter a scene the memory jumps up. This means after say 10 rounds of the game the App crashes. As far as i'm aware after much checking i do not have any retain cycles or strong references to the scenes themselves and whilst i know textures are cached and held in memory surely once preloaded the memory shouldn't be going up each

UIViewController -dealloc method not called

天涯浪子 提交于 2019-11-30 15:48:44
问题 I am working with Automatic Reference Counting. I have a custom UIViewController subclass and whenever I call -presentViewController: animated:completion: or remove its view from the superview I would like to NSLog something like "I am dealloced" so I know that the view controller has successfully been removed. I have implemented the -dealloc method in my view controller. However I started a test project where I just had two UIViewController instances (no retain cycles) and -dealloc is not

UIViewController -dealloc method not called

流过昼夜 提交于 2019-11-30 14:43:06
I am working with Automatic Reference Counting. I have a custom UIViewController subclass and whenever I call -presentViewController: animated:completion: or remove its view from the superview I would like to NSLog something like "I am dealloced" so I know that the view controller has successfully been removed. I have implemented the -dealloc method in my view controller. However I started a test project where I just had two UIViewController instances (no retain cycles) and -dealloc is not called either when I push the second UIViewController modally or when I remove the superview or when I

dealloc in Swift

穿精又带淫゛_ 提交于 2019-11-30 10:32:20
问题 I would like to perform some cleanup at the end of a view controller's life, namely to remove an NSNotificationCenter notification. Implementing dealloc results in a Swift compiler error: Cannot override 'dealloc' which has been marked unavailable What is the preferred way to perform some cleanup at the end of an object's life in Swift? 回答1: deinit { // perform the deinitialization } From the Swift Documentation: A deinitializer is called immediately before a class instance is deallocated.

check retain count

折月煮酒 提交于 2019-11-30 09:08:20
问题 I am doing this : UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainback.jpg"]]; [self.view addSubview:backgroundImage]; NSLog(@" retain count1 : %d " , [backgroundImage retainCount]); [self.view sendSubviewToBack:backgroundImage]; [backgroundImage release]; NSLog(@" retain count2 : %d " , [backgroundImage retainCount]); I got retain count1 : 2 retain count2 : 1 1 ) in dealoc function can i get message like : - (void)dealloc{ NSLog(@" retain count2 :

check retain count

守給你的承諾、 提交于 2019-11-29 12:40:24
I am doing this : UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mainback.jpg"]]; [self.view addSubview:backgroundImage]; NSLog(@" retain count1 : %d " , [backgroundImage retainCount]); [self.view sendSubviewToBack:backgroundImage]; [backgroundImage release]; NSLog(@" retain count2 : %d " , [backgroundImage retainCount]); I got retain count1 : 2 retain count2 : 1 1 ) in dealoc function can i get message like : - (void)dealloc{ NSLog(@" retain count2 : %d " , [backgroundImage retainCount]); [super dealloc]; } And 2) at last i got retain count 1 for

Vector as a class member

走远了吗. 提交于 2019-11-29 00:42:42
Hello I have this question: I would like to have a vector as class member. This is perhaps my question easier for you and I apologize for that. how should I declare the vector? And is this correct? std::vector<int> *myVector; or std::vector<int> myVector ? how should I handle this vector in dealloc? How can I initialize the array into a if? Is this correct? if(myCondition) { if(!myVector) //is this correct? myVector = new std::vector<int>(); //is this correct? on this i have a error } You most certainly want to use std::vector<int> myVector . No need to initialize it, as it gets automatically

Locationservice Indicator stays “on”

我的梦境 提交于 2019-11-28 23:53:37
I have a created a small app which uses location services on the iPhone. All works well, except the fact, that sometimes, the small arrow in the info-bar stays active even if I explicitly kill the app. I use the background mode for locationservices, thus the appDelegate methods applicationWillResignActive , applicationDidEnterBackground , applicationWillEnterForeground and applicationDidBecomeActive are implemented but do not touch the location services (well - I need them in background mode). In that configuration applicationWillTerminate is never called; I implemented all the cleanup cleanup

Dealloc method in iOS and setting objects to nil

爱⌒轻易说出口 提交于 2019-11-28 17:20:11
I have a pretty basic question. In some examples I've seen, objects are just released in the dealloc method. In others, the objects are released and then set to nil . Is there a reason for this? Is setting to nil after releasing advantageous? Three ways to dealloc 1. Just release - (void)dealloc { [airplane release]; [super dealloc]; } Now the object reference points to a random position, which may be one of two things: Most likely it is garbage, because the memory position can't be interpreted as an object. Rarely it will be a different object, because memory have been reused to create a new