AliSoftware / OHAttributedLabel

UILabel that supports NSAttributedString
https://github.com/AliSoftware/OHAttributedLabel/wiki
1.51k stars 344 forks source link

Update OHAttributedLabel/Source/NSAttributedString+Attributes.m #103

Closed orarbel closed 11 years ago

orarbel commented 11 years ago
orarbel commented 11 years ago

since arc does not support autorelease and does not release CF objects, currentFont is leaking.

AliSoftware commented 11 years ago

Nice catch, but a preferrable fix would be to use a __bridge_transfer instead of a simple __bridge (a.k.a. my BRIDGE_CAST macro), as __bridge_transfert is specially designed for such usages. _Or one could also use the Apple's CFBridgeRelease macro that do the same thing (__bridge_transfert cast in ARC, autorelease in MRC)._

So just to let you know, I will probably discard your pull request and fix this issue you spotted using __bridge_transfer instead

orarbel commented 11 years ago

you're right.

AliSoftware commented 11 years ago

Side note: even if I made the code ready to compile using ARC, you're not supposed to compile OHAttributedLabel with ARC turned on (even if your application itself uses ARC).

That's why I explain in the README that you should include the OHAttributedLabel.xcodeproj project as a sibling project in your workspace (as opposed to copy/paste the source files in your application projects, that would make OHAttributedLabel files compile using your application build settings), so that OHAttributedLabel is compiled as a standalone library with its own build settings (including ARC turned off), whatever your application project's settings are.

That's what Xcode workspaces are for. Keeping build settings independant this way make sure there is no conflict or unspecified behavior between components.