Closed ophilbert closed 11 years ago
@ophilbert — I really think ARC is the way to go (and it's highly encouraged by Apple).
The only reason for not using ARC, would be for iOS 4 projects and below. But with iOS 7 (likely) on the way this summer, very few developers will be (or even should be) considering support iOS 4 and below. You can search for iOS version statistics and see that there's a small fraction of users still running iOS 4. Nearly all users have adopted iOS 5.0 and up.
There aren't any good reasons not to use ARC, in my opinion. However, you can always add the -fobjc-arc
compiler flag to these files in your non-ARC project and it should be fine. Or, if you'd like to create a non-ARC branch, I think that would be more appropriate.
"You are strongly encouraged to use ARC for new projects." Memory Management Guide
I though some people may need it. There is not a lot of code to manage it and some people complained about BBUtton crashing see CocoaControls.
In some case you may need to use memory yourself if you want to have a high control on it (big process for example). Anyway you must be right, people should use ARC for their projects.
I'll keep this arc/non-arc branch for people who need it. Sorry for bothering you :)
I agree — it's only a few lines, but I want to encourage the adoption of ARC.
Those crashes in the original demo were because each button was sent addTarget: action: forControlEvents:
but the given @selector
wasn't implemented in the UIViewController
— had nothing to do with ARC, just sloppy coding.
Concerning ARC, many people are not aware that it only applies to Objective-C/Cocoa objects (e.g. NSArray
), NOT CoreFoundation "objects" (e.g. CFArray
). Thus, when using lower-level frameworks (e.g. CoreGraphics
, QuartzCore
, etc.) you must still manage memory (e.g., in BButton
you'll see things like CGColorSpaceRelease(colorSpace)
)
Given all of that, my fork fixes that crash mentioned on CocoaControls and properly manages memory with CoreFoundation and CoreGraphics objects (also fixes a memory leak in the original repo). You can test for potential leaks by selecting Product > Analyze
in the menu bar of Xcode.
And no worries! Not bothering me at all! I almost always accept pull requests, so please continue to contribute. :)
Hi,
It's infortunate that BButton is not working with Non arc project. I previously made a pull request to the original repo https://github.com/mattlawer/BButton/pull/14 but it seems that it' not active anymore.
I added some conditions to check if arc is enabled or not in order to prevent some bridge cast and a crash on non arc project.
It now works perfectly with both arc and non-arc project. Hope it will help people. Regards.
Olivier