How to use a Selector

Just a quick reminder before I forget (again) how selectors are called: Some of Apple’s pre-written methods use whats known as a Selector. Here’s an example method that uses a selector: // create a bar button item UIBarButtonItem *linkButton = [[UIBarButtonItem alloc]initWithTitle:@”My Title” style:UIBarButtonItemStyleBordered target:self action:@selector(myMethod)]; Notice how the selector is created on the second […]

How to remove the first n characters from an NSString

There’s a convenient method for that by the name of substringFromIndex. This example removes the first character: NSString *complete = @”12345″; NSString *cutOff = [complete substringFromIndex:1]; NSLog(@”%@”, cutOff); // cutOff is now 2345 substringFromString takes only one parameter which specifies where to start the new string. The first character is 0 based, like in arrays. […]

How to create a Fetch Request in the Xcode Model Editor

You can create Fetch Requests in the Xcode model editor, including a Predicate. These are somewhat easier to setup. To create one, select your .xcdatamodeld file, then head over to Editor – Add Fetch Request. Give it a catchy name and a filter property, and much of the above code becomes obsolete. Here’s how you […]

How to retrieve a Managed Object in Core Data Fetch Requests

Retrieving Managed Objects is somewhat more complex than creating them, mainly because you can filter what you’re getting back rather than retrieve everything that your store file has to offer. Let’s first illustrate a basic NSFetchRequest. For the following examples I’m using the iOS Master/Detail template which provides an Entity called Event with a property […]

How to create a Managed Object in Core Data

Assuming you’re using an app template that includes Core Data, you will have access to the Managed Object Context. In the simplest form, and without custom Entity classes setup, you can use key/value coding to set your object’s properties. In fact, the Master/Detail template does this. Here’s an example for an Entity named Event with […]

How to create a Save As dialogue with NSSavePanel

Likewise we can save our previously selected file using an NSSavePanel. It too is easy to use, just as the NSOpenPanel. For a save action to make sense we need to have some data to save, so in this example we will copy an existing file (self.myURL) to the new URL that the save panel […]

How to create an Open File dialogue with NSOpenPanel

NSOpenPanel is surprisingly easy to use: create the panel, call the openPanel method, and handle the returned URL object in a block. In this example we invoke the panel from a button in the main window, then display the returned URL in a textLabel: – (IBAction)loadFile:(id)sender { // create an open documet panel NSOpenPanel *panel […]

What to do if you’ve forgotten all credentials to your WordPress site

This podcast describes how to gain access to WordPress even without username, password or working email address. It’s happened to the best of us: you forgot your Password you forgot what User you are even worse, you’ve forgotten which email you’ve used when you installed WordPress worse still, your email no longer exists Fear not, … Read more