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

How to use the first character as a section name

I’m using Core Data for a table view, and I’d like to use the first letter of each of my results as the section header (so I can get the section index on the side). Is there a way to do this with the key path? Something like below, where I use name.firstLetter as the […]

How to convert an NSTimeInterval (seconds) into minutes

I’ve got an amount of seconds that passed from a certain event. It’s stored in a NSTimeInterval data type. I want to convert it into minutes and seconds. For example I have: “326.4” seconds and I want to convert it into the following string: “5:26”. What is the best way to achieve this goal? Thanks.

iOS 7 sizeWithAttributes: replacement for sizeWithFont:constrainedToSize

How do you return a multiline text CGSize from the new iOS 7 method sizeWithAttributes? I would like this to produce the same results as sizeWithFont:constrainedToSize. NSString *text = @”Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus eu urna quis lacus imperdiet scelerisque a nec neque. Mauris eget feugiat augue, vitae porttitor mi. Curabitur […]

Convert NSArray to NSString in Objective-C

I am wondering how to convert an NSArray [@”Apple”, @”Pear “, 323, @”Orange”] to a string in Objective-C.

Check that an email address is valid on iOS

Possible Duplicate: Best practices for validating email address in Objective-C on iOS 2.0? I am developing an iPhone application where I need the user to give his email address at login. What is the best way to check if an email address is a valid email address?

How to set the title of UIButton as left alignment?

I need to display the email address from left side of a UIButton, but it is being positioned in the centre. Is there any way to set the alignment to the left side of a UIButton? This is my current code: UIButton* emailBtn = [[UIButton alloc] initWithFrame:CGRectMake(5,30,250,height+15)]; emailBtn.backgroundColor = [UIColor clearColor]; [emailBtn setTitle:obj2.customerEmail forState:UIControlStateNormal]; emailBtn.titleLabel.font […]

Property declaration help

Possible Duplicate: How does an underscore in front of a variable in a cocoa objective-c class work? I have seen many online examples where they use the following coding style for property declaration: @interface Book : NSObject { NSString *_title; } @property (nonatomic, retain) NSString *title; @end In implementation: @implementation Book @synthesize title = _title; […]

Generating non-repeating random numbers

I want to create a function in C. It will return a random integer in-range of N like:- rand() % N; but the thing is I want to keep track of uniqueness. I don’t want the numbers to repeat. but i can also do this by making an array and copying the generated integers in […]

Instance variables with underscore in Objective-C 2.0 and renaming with @synthetize leads to optimization warnings by the 'Analyze' tool of Xcode 4

Possible Duplicate: How does an underscore in front of a variable in a cocoa objective-c class work? I’m using the same convention for instance variable and properties naming as shown by sebnow in his following answer: instance variable/ method argument naming in Objective C I copy paste his example code here: @interface Foo : NSObject […]

Is there a simple way to split a NSString into an array of characters?

Is there a simple way to split a NSString into an array of characters? It would actually be best if the resulting type were a collection of NSString’s themselves, just one character each. Yes, I know I can do this in a loop, but I’m wondering if there is a faster way to do this […]