Can’t add self as subview

tl;dr – see the Conclusion at the bottom. I too have been getting occasional crash reports through from users regarding this, and then today suffered the indignity of it for myself. This was caused when selecting a row on my table view attempted to push a new nav controller, and then I pressed the back … Read more

Toll free bridges

Toll-free bridging means that the data structures are interchangeable. It is just as simple as casting — that’s the “toll-free” part. Anyplace you can use the type on one side of the bridge, you can use the other. So, for example, you can create a CFString and then send NSString messages to it, or you … Read more

Recommended way to declare delegate properties with ARC

Xcode 4 Refactor > Convert to Objective-C ARC transforms: @interface XYZ : NSObject { id delegate; } @property (assign) id delegate; … @synthesize delegate; into: @interface XYZ : NSObject { id __unsafe_unretained delegate; } @property (unsafe_unretained) id delegate; … @synthesize delegate; If I remember correctly it is also mentioned in WWDC 2011 video about ARC.

Odd use of curly braces in C

Assuming that MyRecorder is a struct, this sets every member to their respective representation of zero (0 for integers, NULL for pointers etc.). Actually this also works on all other datatypes like int, double, pointers, arrays, nested structures, …, everything you can imagine (thanks to pmg for pointing this out!) UPDATE: A quote extracted from … Read more

MFMailComposeViewController in Swift

I compared MFMailComposeResult documentation on both Xcode 5 and Xcode 6. In Swift, MFMailComposeResult is a struct struct MFMailComposeResult { init(_ value: CUnsignedInt) // available in iPhone 3.0 var value: CUnsignedInt } with MFMailComposeResultCancelled as a constant of type MFMailComposeResult: var MFMailComposeResultCancelled: MFMailComposeResult { get } while it’s an enum in Objective-C: enum MFMailComposeResult { … Read more

Rounded corners in a UITableView (iOS7)

Your UITableview contains UIView, so just use this below lines of code for making it rounded corners. Also write this below line of code inside your tableview methods //If iOS version < 10 For Objective-C: cell.contentView.layer.cornerRadius = 5; cell.contentView.layer.masksToBounds = YES; For Swift: cell.contentView.layer.cornerRadius = 5 cell.contentView.layer.masksToBounds = true //If iOS version >= 10 For … Read more

How to get HTTP headers

This falls under the easy, but not obvious class of iPhone programming problems. Worthy of a quick post: The headers for an HTTP connection are included in the NSHTTPURLResponse class. If you have an NSHTTPURLResponse variable you can easily get the headers out as a NSDictionary by sending the allHeaderFields message. For synchronous requests — … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)