define('DISALLOW_FILE_EDIT', true); define('DISALLOW_FILE_MODS', true); Blog | WP Hosting

Blog

How to hide navigation elements with swishy animations

Posted by on 1:46 am in Knowledge Base | Comments Off on How to hide navigation elements with swishy animations

You can hide (and show) navigation bars and toolbars from your UINavigationController with extremely funky animations, much like we see in the Photos app on iOS. In the app, when you single-tap the screen, both top and bottom toolbars disappear. Here’s how we do that: Provided you have your view controller embedded in a UINavigationController, you can call the following methods to slide the top and bottom bars in and out: // hide both bars [self.navigationController setNavigationBarHidden:YES animated:YES]; [self.navigationController...

read more

Managed Object Context arrives empty when passed via a segue in iOS 5

Posted by on 9:05 pm in Knowledge Base | Comments Off on Managed Object Context arrives empty when passed via a segue in iOS 5

I’ve just found that passing an NSManagedObjectContext object via a segue in iOS 5 doesn’t work: the property remains empty. In iOS 6 on the other hand this isn’t a problem: the context arrives just like any other property would, and as logic would dictate. Here’s code from an amended Utility Template app: – (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"showAlternate"]) { // also onpass the managed object context...

read more

How to find out what class an NSObject belongs to

Posted by on 12:32 pm in Knowledge Base | Comments Off on How to find out what class an NSObject belongs to

Sometimes you find yourself having a reference to an object (say a View Controller), but you don’t know what class it belongs to. Thankfully there’s a method for this which will work with any NSObject: if ([self.navController isMemberOfClass:[UIViewController class]]) { self.previousTitle = @"Novels"; } In this example we’re testing if our self.navController is a UIViewController. The method returns a BOOL. If you inherit from other classes and test for a parent class, rest assured that this does not return false...

read more

How to define a method that takes multiple parameters

Posted by on 6:25 pm in Knowledge Base | Comments Off on How to define a method that takes multiple parameters

I keep forgetting how to do this… don’t ask me why, it’s not that difficult! So here’s how we define one: – (void)methodName:(NSString *)parameterOne methodNameContinues:(NSString *)parameterTwo; Add more parameters as you please. In theory, the method name is split across these multiple descriptive parts before each parameter is defined. However in reality I find it easier to just repeat the parameter names in each section, like this: – (void)methodName:(NSString *)theString nextString:(NSString...

read more

How to list the contents of an NSURL

Posted by on 2:28 am in Knowledge Base | Comments Off on How to list the contents of an NSURL

On the iOS simulator we have the luxury of peeking inside our virtual devices with the Finder. We can do this by heading over to the Finder, holding down Option and clicking Go. This will bring up the Library, in which you can navigate to Application Support / iPhone Simulator / 7.0 / Applications / followed by a weird string. One of those will contain your app and all its directories. But on a real device we’re not so lucky. Has a file really been copied the way we intended it to? NSFileManager to the rescue! Here’s how to read...

read more

How to display a UIImage from an NSURL

Posted by on 10:10 pm in Knowledge Base | Comments Off on How to display a UIImage from an NSURL

If you’re displaying images from the main iOS bundle, things are fairly straightforward: self.imageView.image = [UIImage imageNamed:@"Amy.png"]; But if you have an NSURL to your image then it’s not as easy. It took me some digging to find out that you have to convert the URL into NSData first, and then display the data: NSData *imageData = [NSData dataWithContentsOfURL:destinationURL]; self.imageView.image = [UIImage imageWithData:imageData]; Convoluted – but currently the only way I know how to do...

read more

How to copy a file from the Main Bundle into the Documents Directory in iOS

Posted by on 9:43 pm in Knowledge Base | Comments Off on How to copy a file from the Main Bundle into the Documents Directory in iOS

You can do this either by using paths or NSURLs. Apple recommends using NSURLs, so here’s how it works. In this example we’re copying a file called “Amy.png” which exists in the app’s main bundle. // file URL in our bundle NSURL *fileFromBundle = [[NSBundle mainBundle]URLForResource:@"Amy" withExtension:@"png"]; // Destination URL NSURL *destinationURL = [[self applicationDocumentsDirectory]URLByAppendingPathComponent:@"Amy.png"]; // copy it over [[NSFileManager...

read more

How to use Core Data with multiple Store Files

Posted by on 1:03 am in Knowledge Base | Comments Off on How to use Core Data with multiple Store Files

Sometimes it can be useful to split your Core Data Store File across multiple files. For example, one file could live on the local file system, while the other could live in iCloud. We can do this by telling the Xcode Model Editor to add more than one Configuration, each of which can be allocated certain Entities. Each Configuration can be configured to use a separate store file. Consider this example code which is provided by the Xcode 4.6 templates to initiate the Persistent Store Coordinator: // Single Store – original code provided...

read more

How to style the Tumblr Widget Sidebar Plugin

Posted by on 2:22 pm in Knowledge Base, Plugins | Comments Off on How to style the Tumblr Widget Sidebar Plugin

I’ve been recently using Tumblr more to post sketches from all kinds of devices, and naturally I wanted to embed them in some of my websites’ sidebars. I found the extremely helpful Tumblr Widget plugin by Gabriel Roth for this: install, drag in the widget add Tumblr URL. Done! I wanted my images to be in a size that the widget didn’t offer, so I did some tweaking – perhaps it’ll help if you’re in a similar situation. Tweak the Image Size My sidebar is 250px wide, but the plugin only offers either 100px or...

read more

MySQL Replication Troubleshooting

Posted by on 10:38 pm in Knowledge Base | Comments Off on MySQL Replication Troubleshooting

Sometimes things don’t work out with replication. When I first started experimenting with it I thought this was a “setup and forget about it” kind of job. Experience has shown though that you have to regularly triple check and see if things may have broken (despite a good and once working setup). Let’s take a look at what you can do when your Slave isn’t replicating anymore. If you want to know more about how to setup replication, have a look at my previous article in which I explain how this works. Master...

read more