automatic-ref-counting

generateCGImagesAsynchronouslyForTimes in ARC

半世苍凉 提交于 2019-12-06 06:27:25
问题 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);

iOS5 ARC is it safe to schedule NSTimers from background selectors?

China☆狼群 提交于 2019-12-06 06:06:23
问题 I'm trying to debug my application. I've been using some NSTimer instances in my non-arc code like this (from the main thread): [NSTimer scheduledTimerWithTimeInterval:5 target:musicPlayer selector:@selector(playPause:) userInfo:nil repeats:NO]; This works fine if I assign this code to a button and click a button. The timer fires. I've also tried: if( self.deliveryTimer == nil) { self.deliveryTimer = [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(playPause:)

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

落花浮王杯 提交于 2019-12-06 05:50:05
问题 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

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

寵の児 提交于 2019-12-06 04:46:23
问题 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

NSInvocation & NSError - __autoreleasing & memory crasher

我与影子孤独终老i 提交于 2019-12-06 04:43:20
问题 In learning about NSInvocations it seems like I've got a gap in my understanding about memory management. Here is a sample project: @interface DoNothing : NSObject @property (nonatomic, strong) NSInvocation *invocation; @end @implementation DoNothing @synthesize invocation = _invocation; NSString *path = @"/Volumes/Macintosh HD/Users/developer/Desktop/string.txt"; - (id)init { self = [super init]; if (self) { SEL selector = @selector(stringWithContentsOfFile:encoding:error:); NSInvocation *i

ARC warning: Implicit declaration of function 'DLog' is invalid in C99

情到浓时终转凉″ 提交于 2019-12-06 04:31:25
I use DLog macro in an ARC project, and I got the warning: Implicit declaration of function 'DLog' is invalid in C99 You can find DLog from http://iphoneincubator.com/blog/debugging/the-evolution-of-a-replacement-for-nslog How to fix this warning? I actually had this warning when calling Dlog without a capital L. I changed it into DLog and everything worked fine. But you seem to have it correct. Make sure your Prefix.pch file is included in 'Build Settings' -> 'Prefix Header' 来源: https://stackoverflow.com/questions/9799838/arc-warning-implicit-declaration-of-function-dlog-is-invalid-in-c99

Why __weak object will be added to autorelease pool?

冷暖自知 提交于 2019-12-06 04:07:30
id __weak obj1 = obj0; equals id __weak obj1 = obj0; id __autoreleasing tmp = obj0; In Pro multithreading and memory management for iOS and OSX . But why the obj1 need to add to the autorelease pool, I think making a weak pointer of an object should not affect its lifetime. { NSObject* sp = [NSObject new]; NSObject* __weak wp = sp; } the above code is translate to: id sp = objc_msgSend(NSObject, "new"); id wp; objc_initWeak(&wp, sp); objc_destroyWeak(&wp); objc_storeStrong(&sp, 0); 1) obj_initWeak merely associate the weak pointer wp with the strong pointer sp to ensure that when the object

difference between _var and self.var

。_饼干妹妹 提交于 2019-12-06 03:46:24
With all this new ARC stuff (which does not fall under NDA…) coming out, it seems like the default for dealing with properties is to set the property without and ivar in the implementation file explicitly until you synthesize it with something like: @synthesize var = _var; What's the best practice to use in setting the variable? I know the difference between var and self.var is that self.var is using dot notation and is using the var's setter method. Is _var just the equivalent of setting it up within the header files like in the good ol' days? Where did that practice of prefacing everything

Accessor implementation of properties

删除回忆录丶 提交于 2019-12-06 02:03:06
Is there some of documentation how the compiler auto-generates the accessors of properties? When writing custom accessors (overriding the synthesized ones), it would be nice to know the original implementation. Especially to see the differing implementations of accessors for properties with different (weak/strong/retain/copy etc..) attributes. Is there some of documentation how the compiler auto-generates the accessors of properties? The compiler just adds a C function call. Peek at the asm (e.g. _objc_getProperty and _objc_setProperty ). When writing custom accessors (overriding the

Fix potential memory leak in ARC

丶灬走出姿态 提交于 2019-12-06 01:06:11
问题 The following singleton class (SharedManager) helper method might be causing a retain cycle. Getting warnings in static analyzer: "Potential leak of an object allocated at line ..." How can I fix? I did try making ivar uuid __weak but warning still appears when I analyze. NSString *__weak uuid = (__bridge NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject); Thanks Being called in the class like so: myUUID = [SharedManager generateUUID]; + (NSString *)generateUUID { CFUUIDRef