Skip to content →

Category: iOS

Xcode 6 category

After updating to Xcode 6, I thought Apple removed the ability to create a category when creating a new file. I was wrong. They just moved it.

To create a category in Xcode 6, choose File > New > File
xcode6_category1

 

Then select iOS > Source > Objective-C File

xcode6_category2

 

Choose File Type: Category.  Then enter you File name and the class you want to create a category for.

xcode6_category3

Comments closed

How to get the main storyboard

Here’s how to get at the main storyboard from inside your view controller.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] 
bundle:[NSBundle mainBundle]];

Most of the time you can just use self.storyboard. But if you are in a view controller that was not created by a storyboard, then self.storyboard will be nil.

Comments closed

Unable to determine simulator device to boot.

I’ve gotten this message “Unable to determine simulator device to boot.” a few times when trying to run my app in the iOS Simulator.  Unable to determine simulator device to boot. Each time it took me awhile to remember what it meant.

I’ve been working on updating an app to iOS8 and using Xcode 6.    Occasionally I need to run the current version and I start up Xcode 5.   When trying to run the app in the simulator I see this error.

The reason for the error is because the Xcode 6 simulator is already running and it doesn’t know which one to use.  simulator_in_dock

The solution is simple.  Just quit both simulators and try again run again.

 

 

Comments closed

WWDC 2014 – iOS Developer Wish list

As an iOS developer, here are a few things I’d like to see at WWDC 2014

  • Siri Extensibility – I’d like to see Apple open up Siri to third party apps.  For example if I have RunKeeper on my iPhone, I’d like to be able to tell Siri “Start my run”, “End my run”.
  • Blocks added to older API’s – A lot of older API’s are using delegates instead of completion blocks.  For example: UIAlertView
  • UIActivityViewController enhancements – Every time I’ve used UIActivityViewController, I’ve had to extend it to do what I wanted.  It shouldn’t be that hard to share an email where you can specific the recipient, subject, attachment, body, etc..
  • Inter App Communication – I’d like to see something more like Intents on Android.
  • AppleTV SDK – I’d love to be able to write apps for the AppleTV
  • Filesystem – Mac OS X and iOS are due for a new filesystem. ZFS was rumored for awhile but fell through.
  • Multi User iOS – It would be nice if iOS support multiple users, so a family could share an iPad.
Comments closed

ld: library not found for -lPods

I’ve had this error a few times, so I figured I’d document the solution for the next time it occurred.

When doing a build in Xcode, I got the following error:

ld: library not found for -lPods

My project is setup to use cocoapods.

First make sure you are using MyProject.xcworkspace and not MyProject.xcodeproj

For me this was the case.  But I realized that I just created a new configuration for “Ad Hoc” builds.  To fix the problem I had to install the Podfile again with the command:

pod install

After running pod infall, open the project: MyProject.xcworkspace, clean your project and build.  The error should go away.

Comments closed

AddressBookFiller for iOS

AddressBookFiller is a simple application which populates your address book with contacts. It is an updated version of my previous post.

This is useful when developing for the iOS and working on the emulator. On many occasions, I’ve spent quite a bit of time adding contacts to the emulator to test something. Then when I change emulator version, they all get erased. This is very frustrating. So I put together this simple application which allow you to programatically fill up your address book.

Currenly the address book is populated with U.S. Presidents. Values are set for:
* first name
* last name
* photo
* phone number
* birthday
* Address: street, city, state, zip

Source on Github: https://github.com/dougdiego/AddressBookFiller

Comments closed

MHTabBarController

Source: https://github.com/dougdiego/MHTabBarController

I forked MHTabBarController, which is a custom tab bar controller for iOS 5.  I forked it to accomplish two things.

  1. I wanted to use Quartz to draw my arrow instead of using images.
  2. I wanted my arrows to go down in addition to up.

To change the direction of the arrow, just set the pageIndicatorDirection variable like:

MHTabBarController *tabBarController = [[MHTabBarController alloc] init];
tabBarController.pageIndicatorDirection = PageIndicatorDirectionDown;

You can also easily modify the colors in MHTabBarController.m here:

// TAB Colors
#define SELECTED_TAB_COLOR UIColorFromRGB(0xCF785B)
#define SELECTED_TAB_TITLE_COLOR UIColorFromRGBWithAlpha(0xFFFFFF,0.5f)
#define DESELECTED_TAB_COLOR UIColorFromRGB(0xF5EECD)
#define DESELECTED_TAB_TITLE_COLOR UIColorFromRGB(0xAF553A)

ScreenshotDownScreenshotUp

Comments closed

iOS 7 App Redesigns

iOS 7 App Redesigns is a tumblr showing an iOS 7 redesign next to an iOS 6 design. Great site to get you think about how to update your own apps.

ios7_app_redesigns_instagram

Comments closed

mbuzzy iPhone app

mbuzzy iPhone app

For the past couple of months, I’ve been working on an iPhone app for the social networking site: mbuzzy.com. It just went live into the App Store. Check it out: mbuzzy.app

One Comment

Three20: Uploading an image to a server

Here’s an example to upload an image (or any data file) to a server:

- (void) uploadMediaForUserId: (NSString*) userId {	
	NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
								kAPIVersion, @"v",
								nil];
	// Media Name
	if( TTIsStringWithAnyText(_mediaName)){
		[parameters setObject:_mediaName forKey:@"n"]; 
	}
	
	// Media Description
	if( TTIsStringWithAnyText(_mediaDescription)){
		[parameters setObject:_mediaDescription forKey:@"d"]; 
	}
	
	// REST resource, where kMedia: @"/users/%@/media";
	NSString *resource = [NSString stringWithFormat:kMedia, userId];
	
	// Create the URL, where kServerURL is something like "http://www.dougdiego.com"
	NSString *url = [kServerURL stringByAppendingFormat:@"%@?%@", resource, [parameters gtm_httpArgumentsString]];
	// Resulting URL looks like: http://www.dougdiego.com/users/12345/media
	
	TTURLRequest* request = [TTURLRequest requestWithURL:url  delegate:self]; 
	request.httpMethod = @"POST"; 
		
	NSString * imageLocalUrl = [NSString stringWithFormat:@"documents://%@",_mediaFilename];
	NSData *imageData = UIImageJPEGRepresentation(TTIMAGE(imageLocalUrl), 0.6); 
	
	// Set the media file with the parameter: file
	[request addFile:imageData mimeType:@"image/jpeg"  fileName:@"file"]; 
	
	request.cachePolicy = TTURLRequestCachePolicyNoCache;
	request.cacheExpirationAge = TT_CACHE_EXPIRATION_AGE_NEVER;
	
	TTURLJSONResponse* response = [[TTURLJSONResponse alloc] init];
	request.response = response;
	TT_RELEASE_SAFELY(response);
	
	[request send]; 
}
Comments closed