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

Objective-C: NSCommand “airport -s” returning empty

I’m trying to run airport command to scan my wireless networks. Right now, the approach is to use NSTask. I’m running it as follow: NSString *command = [NSString stringWithFormat:@”/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s”]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@”/bin/sh”]; NSArray *args = [NSArray arrayWithObjects:@”-c”, command, nil]; [task setArguments: args]; NSPipe *pipe = [NSPipe pipe]; [task setStandardOutput: […]

iOS MVC – Passing data back and forth to view controllers and model

I’m new to iOS programming and having written a simple reminders style app, I’m now rewriting it to implement the MVC model correctly as previously all my code was inside View Controllers. I have a custom class called Event with properties name, time, repeat etc and then the following structure: Model class Retrieves, processes and […]

Write a method signature including the class name for documentation

Is there a language standard (or common practice) for describing an Objective-C method with the class name included? For example, let’s say I have the following pseudocode: class Foo { void bar(int i); } and I want to write some documentation for it. If this were Java, I would refer to the method as […]

send message to multiple objects at once (objective-c)

(or set multiple objects with one value) Is there a way to send multiple objects one message in one line. So like [someObject, otherObject reset]; like in LUA scripts (which I believe is C?) you can set mutliple objects: someThing, otherThing = 1 , 0

NSURL returning nil for certain cases

I’m creating an NSURL to send as a request to a PHP rest API that I’ve got setup. Here’s my code below: NSMutableString *url = [NSMutableString stringWithFormat:@””,__item,__contactDetails,__lostFound,__explain]; //The ” ‘ ” in PHP is a special character, so we have to escape it in the URL //The two slashes are because the “\” itself is […]

NSPredicate on nested array with NSDictionary as object

i have a NSDictionary like: { “2017-05-02” = ( { “always_valid” = 0; date = “2017-05-02”; from = “12:00”; to = “13:00”; }, { “always_valid” = 0; date = “2017-05-02”; from = “12:00”; to = “12:00”; }, { “always_valid” = 0; date = “2017-05-02”; from = “14:00”; “hourly_rate” = 12; to = “15:00”; } ); […]

Objective-C: Background image and title in Navigation Bar

In need a background image AND a title in my Navigation Bar. For the image I write a category: @implementation UINavigationBar(MyNavigationBar) – (void)setBackgroundImage { UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@”navBarBackgrd.png”]]; [self addSubview: aTabBarBackground]; [self sendSubviewToBack: aTabBarBackground]; [aTabBarBackground release]; } @end I call this category in my AppDelegate and have background images in the whole application: […]

Delete row from table and sqlite database

I still need your help. I have this piece of code that doesn’t want to work. -(void)tableView:(UITableView *)_tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { NSDictionary *rowVals = (NSDictionary *) [shoppingListItems objectAtIndex:indexPath.row]; NSString *keyValue = (NSString *) [rowVals objectForKey:@”key”]; [tableView beginUpdates]; sqlite3 *db; int dbrc; //Codice di ritorno del database (database return code) […]

Using NSUserDefaults for storing UISwitch state

I am trying to persist the UISwitch state in my settings view of my application. Basically it is a UITableView and contains a few switches to get the user preferences. The below code explains how the switches are constructed (only one switch construct is given below, others are also constructed the sameway). if (cell == […]

Access objects of a specific type using for-in loop in Objective C

This question already has an answer here: Fast Enumeration on NSArray of Different Types 5 answers