automatic-ref-counting

if convert project to Automatic Reference Counting(ARC), Is it still support on iOS 3.X, 4.X?

自闭症网瘾萝莉.ら 提交于 2019-11-29 14:06:17
i not sure about convert project to Automatic Reference Counting(ARC). it still support on iOS 4.X or lower ? thank you From what I can gather yes - ARC is done by the compiler and should be thought of as a wizard or helper that checks all of your code and inserts the correct retain and release statements for you. This will therefore be compatible with older iOS runtimes. Edit: IT will support 4.x but not 3.x It will support iOS 4 but not iOS 3. Still, there's no full support for iOS 4 since weak references only work on iOS 5. Quoting the Transitioning to ARC Release Notes directly from Apple:

iOS 5 Blocks ARC bridged cast

柔情痞子 提交于 2019-11-29 13:44:16
问题 This Question references this Question: How to simplify callback logic with a Block? My header has these typedefs typedef void (^StuffDoneBlock)(NSDictionary * parsedData); typedef void (^StuffFailedBlock)(NSError * error); And in init stuffDoneCallback = Block_copy(done); StuffFailedCallback = Block_copy(error); In this paper its says that Block_copy is unnecessary. But then it needs a bridged cast. The compiler message is at follows: error: cast of block pointer type 'StuffDoneBlock' (aka

IOS, ARC, Property: (readwrite, nonatomic) vs (radwrite, retain, nonatomic)

我是研究僧i 提交于 2019-11-29 12:59:57
I am have read up some tutorials on ARC and am still left a bit confused on properties declarations. I wrote most most my code using the following pattern: @property (readwrite, nonatomic) PlayerData* playerData; @property (readwrite, nonatomic) MusicLayer* musicLayer; @property (readwrite, nonatomic) bool isPowerUpAvailable; Now that I finally started to deal with memory leaks XCode suggested me that in some bits of code I should have added the "retain" keyword in the property declaration. Using ARC I thought I shouldn't "Bother" about retain counts anymore. Is there some concept I am not

xcode ARC conversion error [CFString retain] crash

流过昼夜 提交于 2019-11-29 12:50:46
I converted my huge IOS program to ARC using xcode auto conversion. After that I am getting the following error: [CFString retain]: message sent to deallocated instance The trace shows the following line where it crashed: UIImage *image = [[UIImage alloc] initWithContentsOfFile:tile.imagePath]; Next line in the trace gives:__arclite_objc_retainAutoreleasedReturnValue at /SourceCache/arclite/arclite-7.1/source/arclite.m:241 Can someone suggest me where I can look further, or what can I do to remove this crash? Thanks a lot EDIT: Looks like the (NSString *)p initialization in the code below

Manual object lifetime with ARC

一个人想着一个人 提交于 2019-11-29 12:38:51
Examine the following code, and assume it was compiled under ARC: - (void)foo { NSOperationQueue *oq = [[NSOperationQueue alloc] init]; [oq addOperationWithBlock:^{ // Pretend that we have a long-running operation here. }]; } Although the operation queue is declared as a local variable, its lifetime continues beyond the scope of the method as long as it has running operations. How is this achieved? UPDATE: I appreciate Rob Mayoff's well-thought-out comments, but I think I did not ask my question correctly. I am not asking a specific question about NSOperationQueue, but rather a general

UIWebView taking lots of memory

六眼飞鱼酱① 提交于 2019-11-29 12:28:40
问题 In my app when i load UIWebView with any Website url the memory jumps from 30mb to around 140mb. I am using ARC and when dismissing the UIWebViewController [ Viewcontroller which contains UIWebView], it doesnt releases the memory. Can any body help me how to solve this memory issues as well as please also provide me pointers of memory bestpractices in ARC For loading the webpage :- NSURL *nsurl=[NSURL URLWithString:self.url]; NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];

Why is my object's weak delegate property nil in my unit tests?

自闭症网瘾萝莉.ら 提交于 2019-11-29 12:03:32
问题 I have a pretty simple setup for this unit test. I have a class that has a delegate property: @interface MyClass : NSObject ... @property (nonatomic, weak) id<MyDelegateProtocol> connectionDelegate; ... @end and I set the delegate in my test: - (void)testMyMethod_WithDelegate { id delegate = mockDelegateHelper(); // uses OCMock to create a mock object [[delegate expect] someMethod]; myClassIvar.connectionDelegate = delegate; [myClass someOtherMethod]; STAssertNoThrow([delegate verify], @

Why Swift closure not capture self?

本秂侑毒 提交于 2019-11-29 10:37:53
I was testing swift closure with Xcode playground. This is my code: import UIKit class A{ var closure: ()->() = {} var name: String = "A" init() { self.closure = { self.name = self.name + " Plus" } } deinit { print(name + " is deinit") } } var a: A? a = A() a = nil As what is expected, a is self contained by closure, so a is never released. But, when I add this line before the last line: a?.closure = { a?.name = "ttt" } Then, I found "A is deinit" in the output window, which means a is released. Why? is a not recycle reference? To be test, I use a function to set the closure, which the code is

NSThreads in Automatic Reference Counting(ARC)

旧巷老猫 提交于 2019-11-29 10:27:00
i am trying to use NSThreads with ARC in 4.3.5. With iOS 5 everything works perfect, but if i try it on a older iOS like 4.3 its leaking. Normally i would use a Autoreleasepool for NSThreads but since there is no manual Autoreleasepool in ARC i don't know how to fix this. I get loads of Messages like "__NSAutoreleaseNoPool(): Object 0x4567b40 of class NSComparisonPredicate autoreleased with no pool in place - just leaking" in my Console after i start a Thread. NSThread detachNewThreadSelector:@selector(showAlert) toTarget:self withObject:nil]; How to correctly thread with ARC and iOS prior to

Objective-C: ARC forbids explicit message send of 'retain'

天涯浪子 提交于 2019-11-29 09:50:39
I'm new to Objective-C, I try to port an old Objective-C project written in an older version of Objective-C to the new one, but I'm getting the following compiler error: ARC forbids explicit message send of 'retain' in color = [aColor retain]; or color = [[NSColor blackColor] retain]; I was reading about the new automatic reference counting that clang is using now. I have also tried to use Xcode's refactor function but with no luck... What is the proper Objective-C code that need to replace this old code? Simply: color = [NSColor blackColor]; ARC will manage the lifetime of your objects so you