automatic-ref-counting

How to free memory in ARC for high memory usage graphics render?

泪湿孤枕 提交于 2019-12-04 11:25:23
First off, thank you to everyone on this site...it's been INCREDIBLY helpful in getting into the grit of iOS programming. My current issue: I have an app that renders a very stylized version of a photo. It uses some CoreImage filters for some of it, but needs a bunch of CoreGraphics to get the heavy image processing done. The proxy size renders work out great, but when I render a full resolution version of my image, it sometimes crashes because of high memory usage. The problem is that I need to be able to have several full resolution (3264x2448) buffers in memory when rendering. I don't know

iOS: __weak vs (weak)

和自甴很熟 提交于 2019-12-04 11:23:55
Are there a differences between these two lines of code? __weak IBOutlet UITextField *usernameField; @property (weak) IBOutlet UITextField *usernameField; What if you declare either of these in interface section of the .h or the .m files? Yes. The first example declares a weak instance variable called usernameField , but the second declares a weak property called usernameField , and an instance variable called _usernameField that is accessed by the property. If you declare it in an @interface section of the .m file, then it can only be accessed in that .m file (unless you mess with the

message sent to deallocated instance using Pinterest SDK

寵の児 提交于 2019-12-04 11:12:09
I'm using the Pinterest iOS SDK to share an item in my iPad app. The following snippet of code will always crash with a message sent to deallocated instance on the line with the comment: NSString *clientId = [NSMutableString stringWithString:@"1431665"]; NSLog(@"clientId: %@", clientId); Pinterest *pinterest = [[Pinterest alloc] initWithClientId:clientId]; NSLog(@"gone: %@", clientId); // <- CRASH! I'm using NSMutableString stringWithString to simulate the conditions in my app. I don't actually use that line in my code. Even if don't output the clientId on the last line, the app crashes when

How to release a Firemonkey control properly, in this case a child form with a parent?

瘦欲@ 提交于 2019-12-04 10:22:22
From inside an event handler of the control itself, I would like to delete and free it. A typical use case for TFmxObject.Release , isn't it? However, it only seems to work under Windows, but not Android, and this method is now deprecated anyway. I know, doesn't work is not a good problem description, but currently I'm not able to debug it under android. Under Windows, I see that the event handler continues correctly after the .Release and after it finished, my log message inside my controls destructor is executed. Under Android, the application hangs. When I use .Free instead, it still works

Objective-C - weak property - getter autoreleases (Automatic Reference Counting)

删除回忆录丶 提交于 2019-12-04 10:16:46
I have a doubt regarding weak property in ARC (auto reference counting) My understanding (correct me if I am wrong): weak property behaves similar to the assign property except that when the instance that the property was pointing to gets destroyed, the ivar is made to point to nil. Question: I just feel that the getter of the weak property retains and autoreleases. Isn't it suppose to behave like getter of the assign property where the getter doesn't retain and autorelease ?(pls refer to the program) Program: I have given below the program with the actual output and my expected output. Note -

Inconsistent object deallocation with ARC?

纵饮孤独 提交于 2019-12-04 09:29:29
问题 I was playing around with memory (de)allocation stuff on a simple command line app for Mac OSX 10.7 built using Xcode Version 4.2.1 with ARC enabled, and the default build settings. I can't explain the behaviour I'm getting from what I understand about ARC, so I'm hoping someone can explain what's going on here. First off, in the following code I'm getting the behaviour I expect (please note that the NLog() output is given in the comment after the corresponding statement) #import <Foundation

generateCGImagesAsynchronouslyForTimes in ARC

爱⌒轻易说出口 提交于 2019-12-04 09:27:46
If I run the following in a project where ARC is enabled the completion handler never fires. But without ARC it works as expected. What am I missing here? NSURL *url = [NSURL URLWithString:@"http://media.w3.org/2010/05/sintel/trailer.mp4"]; AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:url options:nil]; AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; generator.appliesPreferredTrackTransform = YES; CMTime thumbTime = CMTimeMakeWithSeconds(5,30); AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime,

View based NSTableView EXC_BAD_ACCESS on Lion with ARC

别等时光非礼了梦想. 提交于 2019-12-04 09:08:45
This is weird. I've got a super simple project to learn NSTableView, and it's set up in my nib, set as a View-based tableView. I've also set the dataSource and delegate to my controller obejct. When I do this, however, and run, I get an EXC_BAD_ACCESS, with the trace starting in my main function and the rest of the stack is internal to Cocoa (so not my code). There's really nothing fancy going on, other than this project is using ARC (it's a new project, so this was the default). I also tried using the Analyzer to make sure I wasn't improperly doing memory managment anywhere and there were no

How to get notified when a zeroing weak reference becomes nil on Objective-C under ARC?

那年仲夏 提交于 2019-12-04 08:56:36
问题 Is there a mechanism which would allow an object to know that a zeroing weak reference turned nil? For example I have a property @property (nonatomic, weak) MyClass *theObject; when theObject deallocates and the property turns nil I want to get notified. But how? Does the zeroing weak reference system use the setter to set the property to nil when the object goes away? 回答1: The runtime just sets the weak ivar _theObect to nil, a custom setter is not called. What you could do (if you really

Pointer casting with ARC

别来无恙 提交于 2019-12-04 08:16:02
问题 ARC is giving me a hard time with following cast: NSDictionary *attributes; SecItemCopyMatching((__bridge CFDictionaryRef)keychainItemQuery, (CFTypeRef *)&attributes); Error: Cast of an indirect pointer to an Objective-C pointer to 'CFTypeRef ' (aka 'const void * ') is disallowed with ARC 回答1: The problem is that attributes shouldn't be a dictionary, it should be a SecKeyRef or CFDataRef. And then cast that back into NSData for the password data copied into it. Like so: CFDataRef attributes;