iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

With ARC, what's better: alloc or autorelease initializers?

Is it better (faster & more efficient) to use alloc or autorelease initializers. E.g.: – (NSString *)hello:(NSString *)name { return [[NSString alloc] initWithFormat:@”Hello, %@”, name]; } OR – (NSString *)hello:(NSString *)name { return [NSString stringWithFormat:@”Hello, %@”, name]; // return [@”Hello, ” stringByAppendingString:name]; // even simpler } I know that in most cases, performance here shouldn’t […]

ARC forbids Objective-C objects in structs or unions despite marking the file -fno-objc-arc

ARC forbids Objective-C objects in structs or unions despite marking the file -fno-objc-arc? Why is this so? I had the assumption that if you mark it -fno-objc-arc you don’t have this restriction.

How to write a simple Ping method in Cocoa/Objective-C

I need to write a simple ping method in Cocoa/Objective-C. It also needs to work on the iPhone. I found an example that uses icmp, will this work on the iPhone? I’m leaning towards a solution using NSNetServices, is this a good idea? The method only needs to ping a few times and return the […]

How to give space between two cells in tableview?

I want a space between two cell in table view, I want cell like this, How can i do that?

IPhone/IPad: How to get screen width programmatically?

Hi I’m wondering if there’s a way to get the width programmatically. I’m looking for something general enough to accomodate iphone 3gs, iphone 4, ipad. Also, the width should change based on if the device is portrait or landscape (for ipad). Anybody know how to do this?? I’ve been looking for a while… thanks!

How to use single storyboard uiviewcontroller for multiple subclass

Let say I have a storyboard that contains UINavigationController as initial view controller. Its root view controller is subclass of UITableViewController, which is BasicViewController. It has IBAction which is connected to right navigation button of the navigation bar From there I would like to use the storyboard as a template for other views without having […]

Just two rounded corners?

This question already has an answer here: Rounded UIView using CALayers – only some corners – How? 12 answers

How do I set recipients for UIActivityViewController in iOS 6?

I’m using the new UIActivityViewController class in iOS6 to provide the user with various sharing options. You can pass an array of parameters to it such as text, links and images and it does the rest. How do I define recipients? For example sharing via mail or SMS should be able to accept recipients but […]

How do I create a temporary file with Cocoa?

Years ago when I was working with C# I could easily create a temporary file and get its name with this function: Path.GetTempFileName(); This function would create a file with a unique name in the temporary directory and return the full path to that file. In the Cocoa API’s, the closest thing I can find […]

How to use NSXMLParser to parse parent-child elements that have the same name

Does anyone have some idea how to parse the following xml using event-driven model NSXMLParser class? <Node> <name> Main </name> <Node> <name> Child 1 </name> </Node> <Node> <name> Child 2 </name> </Node> </Node> I want to collect all three names from this xml file, is it possible, or I have to change to Tree-based parsing?