dealloc

How to use dealloc when dealing with auto-synthesized properties?

不打扰是莪最后的温柔 提交于 2019-12-24 08:57:36
问题 I'm relatively new to iOS development so please excuse me if this is a retarded question. I've read this but am still a bit confused. I'm not using ARC. (Yes yes, I know I should but I don't at this point) In my class header I have this /*-----------------------------------------------------------------------+ | The name of the sender/receiver +-----------------------------------------------------------------------*/ @property (nonatomic, retain) NSString *name; I do NOT synthesize this

Issues with NSOperationQueue and dealloc being called and crashing App

家住魔仙堡 提交于 2019-12-24 07:03:27
问题 I've created an NSOperation in the queue like so: ImageLoadingOperation *operation = [[ImageLoadingOperation alloc] initWithImageURL:url target:self action:@selector(didFinishLoadingImageWithResult:)]; [operationQueue addOperation:operation]; [operation release]; And this works fine but if the view gets popped before the operation finishes the App crashes with "EXC_BAD_ACCESS" I've tried to cancel the the operation Queue by calling cancelAllOperations but as its already in process it doesn't

Hooking end of ARC dealloc

你离开我真会死。 提交于 2019-12-24 03:08:01
问题 Given the following simple implementation: @implementation RTUDeallocLogger -(void)dealloc { NSLog(@"deallocated"); } @end we run the following code under ARC: @implementation RTURunner { NSArray* arr; } -(void)run{ arr = [NSArray arrayWithObjects:[[RTUDeallocLogger alloc]init], [[RTUDeallocLogger alloc]init], [[RTUDeallocLogger alloc]init], nil]; NSLog(@"nulling arr"); arr = NULL; NSLog(@"finished nulling"); } @end we get the following log output: nulling arr finished nulling deallocated

UIDocument never calling dealloc

旧巷老猫 提交于 2019-12-23 19:45:24
问题 I have an issue where I can't seem to dealloc UIDocument (used in iCloud) After running an NSMetaDataQuery to look for the document as follows.. NSMetadataQuery *query = [[NSMetadataQuery alloc] init]; _query = query; [query setSearchScopes:[NSArray arrayWithObject: NSMetadataQueryUbiquitousDocumentsScope]]; NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K == %@", NSMetadataItemFSNameKey, kFILENAME]; [query setPredicate:pred]; [[NSNotificationCenter defaultCenter] addObserver:self

Objective-C: Do you have to dealloc property objects before deallocating the parent object?

[亡魂溺海] 提交于 2019-12-23 10:10:51
问题 Let's say I have an object named "foo" with another object named "bar" as property. When "foo" deallocates, will it automatically remove all references to "bar" so that "bar" deallocates as well? or will "foo" deallocate and "bar" float in memory somewhere? even if all of "bar"'s references are defined in "foo". thanks in advance. 回答1: If the foo object has any retains on or copies of (thanks Dave) bar , for example when you declare the property as either one of these: @property (nonatomic,

UISplitViewController: Deinit DetailView in collapsed mode

青春壹個敷衍的年華 提交于 2019-12-22 05:58:49
问题 I've been struggling on this for a while now, but I wasn't able to find a solution: I've got an iOS 9 app that supports all device families, uses size classes and is programmed with Swift 2.0. I'm using a UISplitViewController and everything works as I want, except in a collapsed environment (e.g. on an iPhone). The Master-ViewController is a UITableViewController that triggers a replace segue when a cell is selected. In a collapsed environment this means, that the detailViewcontroller gets

Memory leak with UIWebView

天涯浪子 提交于 2019-12-22 04:59:15
问题 My project is a hybrid static lib for showing a UIWebView with some JS to control the logic. When I use 64bit and run demo on iOS 8/iPhone 6, the memory keeps going to 30M or more! When I use generation in instrument, the increased memory usage is almost all from webcore; does it means there are leaks in JS code? I can't find a leak when I use Safari to run similar JS directly. When I release the UIWebView, the memory is still not freed; I tested with instrument allocation. There are some

UIViewController & UIview dealloc not getting called

混江龙づ霸主 提交于 2019-12-22 04:42:54
问题 I have a Navigation based view controller and in the view controller i have hidden the top navigation bar and use a custom UIView as the navigation bar. The UIView bar has a back button and I use Delegate methods(I have declared a protocol) to communicate to the view controller when the back button is preesed. I use delegate in my CustomNavigation Bar id delegate; and In the main View Controller when i allocate the navigation bar i set the delegate topBar = [[TopNavigationBar alloc]

Force explicit deletion of a Java object

自古美人都是妖i 提交于 2019-12-22 01:56:18
问题 I'm working on a Java server that handles a LOT of very dense traffic. The server accepts packets from clients (often many megabytes) and forwards them to other clients. The server never explicitly stores any of the incoming/outgoing packets. Yet the server continually runs into OutOfMemoryException exceptions. I added System.gc() into the message passing component of the server, hoping that memory would be freed. Additionally, I set the heap size of the JVM to a gigabyte. I'm still getting

NSTimer disables dealloc in UIView

Deadly 提交于 2019-12-20 12:38:48
问题 @interface someview:UIView{ NSTimer* timer; } @end @implementation someview -(void)dealloc{ NSLog(@"dealloc someview"); [timer invalidate]; timer = nil; } -(void)runTimer{ // } -(void)someMethod{ timer = [NSTimer timerWithTimeInterval:2.0f target:self selector:@selector(runTimer) userInfo:nil repeats:YES]; } @end Releasing someview will NOT call dealloc and the timer keeps on running. If I comment out the "timer = [NSTimer schedule...." part, dealloc will be called. Which means all the other