Showing posts with label oebjective-c. Show all posts
Showing posts with label oebjective-c. Show all posts

Friday, January 3, 2014

Detecting The iPhone Device Type

I’m having an issue when I deploy my app my phone. I am currently building the app on a 3gs, when the view is displayed, it is the iPhone 5 layout that shows, which makes some objects display partially off of the screen.

You can use the [UIDevice currentDevice] class method. This will donate you information approximately the device like systemName, systemVersion, model, etc.

If you need to obtain the screen dimensions instead, you could use the [UIScreen mainScreen] class method. With it you could obtain the applicationFrame or the screen bounds.

Hope this helps!

Monday, October 14, 2013

filter array using NSPredicate for Names with beginning strings

I want to filter an array of Names (strings) which will be starting with a specific String in first name or last name. For example i have to obtain search results “Joel Mathew” & “Steve Joe” if i gave the string “Jo” to search. Thanks in advance.

Try this.

NSString *nameFilter = @"Steve*";NSPredicate *pred = [NSPredicate predicateWithFormat:@"(name like %@", nameFilter];

Then, filter the array

NSArray *personArray = /* obtain from somewhere */;NSArray *filtered = [personArray filteredArrayUsingPredicate:pred];NSLog(@"%@",filtered);