iphone - How can I fix this error: "ARC forbids explicit message send of 'release' in Xcode" -


this question has answer here:

i'm trying make simple animation image in iphone image array:

- (void)viewdidload {     nsarray *imagearray;     imagearray = [[nsarray alloc] initwithobjects:                   [uiimage imagenamed:@"sun1"],                   [uiimage imagenamed:@"sun2"],                   nil];     fadeimage.animationimages = imagearray;     fadeimage.animationduration = 1;     [imagearray release];  //==== here error ====== 

how can fix this?

solution #1:

just remove release statement. arc manage you.

[imagearray release]; // remove line 

arc auto reference counting. opposite manual reference counting.
there few great videos of talks wwdc. can provide link if wish watch them.

in transitioning arc release notes, see arc enforces new rules:

you cannot explicitly invoke dealloc, or implement or invoke retain, release, retaincount, or autorelease.

the prohibition extends using @selector(retain), @selector(release), , on.

solution #2:

if not wish convert code arc (e.g. not writing new application, maintaining old 1 / or imported code moving arc not worth it) can disable arc.

  • disabling arc selected files disable arc, can use -fno-objc-arc compiler flag specific files. select target , go build phases -> compile sources. edit compiler flags , add -fno-objc-arc.

  • disabling arc project
    source:how disable xcode4.2 automatic reference counting

    • click on project, in left hand organizer.
    • select target, in next column over.
    • select build settings tab @ top.
    • scroll down "objective-c automatic reference counting" (it may listed as
    • "clang_enable_objc_arc" under user-defined settings group), , set no.

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -