Tuesday, November 20, 2012

The White Party iPhone App

For anyone interested... Alive Mobile has released an impressive iPhone app for the Sydneys Digital industry annual White Party available on the App store here:


 https://itunes.apple.com/au/app/the-white-party/id576995647?mt=8

 Party's in 9 days @ the Beresford hotel, Surry hills.
 Some of our team including myself are gonna rock along. Should be a good night.






Some Screenshots:


One of their promo vids:








Wednesday, September 5, 2012

The Linkedin API with OAuthStarterKit

An iOS app I've been working on at work, requires me to use OAuth with linkedin, to use the app users data for autofilling in a job application

I started with git: https://github.com/synedra/LinkedIn-OAuth-Sample-Client

And immediately got the error "signature_invalid" returned, when calling for any specific field selections.

 I eventually sussed it and answered my own question in how to get it to give me the users authorized data including their email, telephone, address, job history etc etc.

The raised question was here:
linkedin-api-error-invalid-signature-in-iphone-starter-kit

The profile usage link here:

https://developer.linkedin.com/documents/profile-api

I'm able to get the users email address which conflicts with official information from Linkedin's site (Depending on where you look) e.g. here a Linked in staff member explains that email is not given out to protect their users:
https://developer.linkedin.com/forum/getting-started-linkedin-api-read-first

Saturday, August 18, 2012

Come Get Me App - Submitted to the appstore


So with Nick Flower on UI, Brad Hircock on marketing and myself coding we built an iPhone utility app called 'Come Get Me'. A one click SMS builder for requesting pick up from your current location using CoreLocation (GPS/network triangulation).

We got the domain name comegetmeapp.com and thanks to Brad and Nick a nice splash page and twitter account set up.

Potentially a useful SOS utility when needing a pick up in situations where it's difficult to make a phone call. E.G. a nightclub. Using Google reverse Geolocation it can fairly accurately autofill your location and provide a maps link in the SMS using the Google URL shortener API.

We chucked some analytics into the app, as well as a feed back form, so we may change / add functionality and/or design depending on the popularity and demographics usage.



Screenshots:






















The copy to go on the app store description:
The app will help you to forget those awkward conversations where you have to explain where you are and how you got there, instead the app will do that for you. Come Get Me detects your location and remembers your favourites so all you have to do is tap a single button when you need to be picked up. 
If you find us a bug or have a suggestion for improvement let us know using the feedback button below. 
Click Come Get Me, sends a link to your location on Maps Instantly via SMS to your car owner (mate, Mum, Dad, girlfriend, office assistant) of choice. 
This is the first release, please give feedback on how we can improve this app! 

This app brought to you by Brad, Dave and Nick

Upgrading my Macbook Pro (Early 2011)

Currently I run a Macbook Pro with 2 HD's (120 GB Intel 3GB/s SSD and a 700GB 7200 RPM with 4GB stock Apple RAM dual booted between OSX Mountain Lion and Windows 7.

Today I ordered a few parts for my yearly upgrade.

The Upgrade:
1. Chuck in 16 GB Ram - GSkill (1.5V) 2 x 8GB. $100 AUD - G.SKILL 16GB (2 x 8G) 204-Pin SO-DIMM DDR3 1333 (PC3 10600) Laptop Memory F3-10600CL9D-16GBSQ
2. 512 GB Crucial M4 SSD in the main disk bay. $435 inc shipping Crucial 512 GB m4 2.5-Inch Solid State Drive SATA 6Gb/s CT512M4SSD2
3. External case for 700GB $25

The plan:
Move the 120GB to the opti-bay slot. As the CD Drive bay as a max through put of 3GBs on the 2011 mbp's.
Use Clonezilla to take a full image of the Bootcamp partition OSX and Win7 partitions on the 120GB
Chuck in the 512GB.
Restore the bootcamp osx/ntfs image to the 512GB. Create a partition for OSX and win7( Exfat), move all of the tools/apps/games that were installed on the 700GB to the respective drive.
Partition the 120 to 80GB HFS+ and 40 EXFat.

As long as I can get the state logically the same as before I'll be in a good position, the 120GB is over a year old so I'm happy to move my most critical work related tools to the new faster bigger SSD, demote the intel 120GB to a file storage device and use the 700 GB as my backup HD.

OSX Will look like:
OS Drive - 128 GB - {XCode, Photoshop, Documents, Tools}
HFS Data - 128 GB - {iTunes, Downloads}
EXFat 80GB - {Media (TV Shows etc)}

Windows 7 Will look like:
C:\ 128 GB NTFS {Visual Studio/Photoshop/ Anything that doesn't need registry key changes}
D:\ 128 GB EXFat {Steam games}
E:\ 40 GB ExFat {Downloads}

Wednesday, August 24, 2011

Decorator, Builder and Factory Design Patterns in Objective C

Some people get confused with these 3 patterns (Like me), for you objective c programmers I've rewritten the 3 patterns in example implementations and uploaded them to github, if you can do better, by all means tell me and I'll use your link instead.

Decorator
Builder
Factory Method

All 3 patterns are similar in their achievement of decoupling code, but they have unique purposes and it's necessary to understand these differences, and for those with a visual brain, it's best to see the code alongside reading about them.

If you're a learning cocoa/objective c programmer and you know the time savings incurred from good use of design patterns then you'll gain a lot of key notes from this book: Cocoa Design Patterns



http://en.wikipedia.org/wiki/Decorator_pattern
http://en.wikipedia.org/wiki/Builder_pattern
http://en.wikipedia.org/wiki/Factory_method_pattern

But to see the value in these patterns, it's necessary to consider the alternatives and Anti-Patterns, and even make some real world mistakes...

Decorator Pattern
https://github.com/mrdavenz/DVDecorator
For those without git, the Decorator Pattern code is copy and paste-able at the bottom of this post.

Builder Pattern
https://github.com/mrdavenz/DVBuilder

Here is a decent enough UML diagram of the Builder Pattern (Found here http://www.dofactory.com/Patterns/PatternBuilder.aspx)

Also a pretty good description is found here: http://www.codeproject.com/KB/architecture/Builder_Design_Pattern.aspx

In the source example, you have a Shop (Director), which has a suite of Custom Builders available, they can be interchanged at run time. If the user asks for a Motorcycle, the Shop owner can simply tell the code to build one using the Builder, and the custom attributes for a motorbike are built.

Without the builder pattern, a developer would simply have more code, and a higher dependence, which over time can reduce readability and discourage the reuse of the code.

So depending on the context, the benefits of the Builder pattern are subtle, but worth using when applicable.

Also don't confuse Builder with Factory:
http://en.wikipedia.org/wiki/Factory_method_pattern

Factory Method
https://github.com/mrdavenz/DVFactoryMethod

The Factory pattern can almost be seen as a simplified version of the Builder pattern.

In the Factory pattern, the factory is in charge of creating various subtypes of an object depending on the needs.

The user of a factory method doesn't need to know the exact subtype of that object. An example of a factory method createCar might return a Ford or a Honda typed object.

In the Builder pattern, different subtypes are also created by a builder method, but the composition of the objects might differ within the same subclass.

To continue the car example you might have a createCar builder method which creates a Honda-typed object with a 4 cylinder engine, or a Honda-typed object with 6 cylinders. The builder pattern allows for this finer granularity.
Often, designs start out using Factory Method (less complicated, more customizable, subclasses proliferate) and evolve toward Abstract Factory, Prototype, or Builder (more flexible, more complex) as the designer discovers where more flexibility is needed.
Sometimes creational patterns are complementary: Builder can use one of the other patterns to implement which components get built. Abstract Factory, Builder, and Prototype can use Singleton in their implementations.

A great comparison on stackoverflow found here:

what-is-the-difference-between-builder-design-pattern-and-factory-design-pattern

The Builder class is often used to build complex objects step by step, perhaps ordering matters. And is frequently used in conjunction with the Composite pattern, http://en.wikipedia.org/wiki/Composite_pattern, the common composite example in Cocoa UIKit is the use of UIView, where UIView has can have many subViews, that all have a common set of attributes, such as the Frame Size.

In iOS this pattern is analogous to the


Further reading:

builder-vs-decorator-pattern


#import 

@interface Car : NSObject

- (NSString *) getDescription;
- (double) getPrice;

@end

#import "Car.h"

@implementation Car

- (id)init
{
    self = [super init];
    if (self) {
        // Initialization code here.
    }
    
    return self;
}

- (NSString *) getDescription{
    return @"Car";
}

- (double) getPrice{
    return 99999.0;
}

@end



#import "Car.h"

@interface FamilyCar : Car{
    
@private
    Car *car;
}

- (id)initWithCar : (Car *) theCar;

@property (assign) Car *car;

@end

#import "FamilyCar.h"

@implementation FamilyCar

@synthesize car;

- (id)initWithCar : (Car *) theCar{
    self = [super init];
    if (self) {
        // Initialization code here.
        self.car = theCar;
    }
    
    return self;
}

- (NSString *) getDescription{

    return [NSString stringWithFormat: @"%@::FamilyCar", self.car.getDescription];
}

- (double) getPrice{

    return  (self.car.getPrice + (self.car.getPrice * 0.1));
}

@end



#import "Car.h"

@interface Sunroof : Car{

@private
    Car *car;
}

- (id)initWithCar : (Car *) theCar;
- (NSString *) getDescription;
- (double) getPrice;

@property (assign) Car *car;

@end

#import "Sunroof.h"

#pragma mark -
#pragma mark Private Methods go here.

@interface Sunroof()

@end

#pragma mark -
#pragma mark Implementation

@implementation Sunroof

@synthesize car;

- (id)initWithCar : (Car *) theCar{
    self = [super init];
    if (self) {
        self.car = theCar;
    }
    
    return self;
}

- (NSString *) getDescription{
    
    return [NSString stringWithFormat: @"%@::Sunroof", self.car.getDescription];
}

- (double) getPrice{
    
    return  (self.car.getPrice + (self.car.getPrice * 0.2));
}

@end



#import "Car.h"

@interface Airbag : Car{
    
@private
    Car *car;
}

@property (assign) Car *car;

- (id)initWithCar : (Car *) theCar;
- (NSString *) getDescription;
- (double) getPrice;

@end
#import "Airbag.h"

@implementation Airbag

@synthesize car;

- (id)initWithCar : (Car *) theCar{
    self = [super init];
    if (self) {

        self.car = theCar;
    }
    return self;
}

- (NSString *) getDescription{
    
    return [NSString stringWithFormat: @"%@::Airbags", self.car.getDescription];
}

- (double) getPrice{

    return  (self.car.getPrice + 220.0);
}

@end


I chose to test the code in my App Delegate didFinishLaunchingWithOptions method:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    
    Car *standardCar = [[Car alloc] init];
    
    NSLog(@"standardCar: %@ for $%.2f", standardCar.description, standardCar.getPrice);
    
    Car *carWithAirbags = [[Airbag alloc] initWithCar : standardCar];
    
    NSLog(@"carWithAirbags: %@ for $%.2f", carWithAirbags.description, carWithAirbags.getPrice);
    
    Car *carWithEverythingElse = [[Sunroof alloc] initWithCar : [[FamilyCar alloc] initWithCar: carWithAirbags]];
    
    NSLog(@"carWithEverythingElse: %@ for $%.2f", carWithEverythingElse.description, carWithEverythingElse.getPrice);
     
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    
    return YES;
}

This example was inspired from the Java implementation here : http://java.dzone.com/articles/design-patterns-revisited-2-de

For some further language agnostic discussion on the matter read here:
http://stackoverflow.com/questions/4768349/builder-vs-decorator-pattern



Sunday, August 7, 2011

Net Insight Web Analytics on native iPhone

If anyone needs the code, to post to their web analytics data store, Its on github.
https://github.com/mrdavenz/DVDNetInsightTracking

Tuesday, June 21, 2011

Multiple UIButtons on the UINavigationBar

I needed multiple buttons on the rightBarButtonItem in my navigation bar.

Below is the code I used, notice that I use a subclass of UIToolbar, but using the UIToolbar directly will render the same result.

I originally got the idea from HERE but it wasn't exactly what I needed, so I modified it to fit my needs.




.
.
.
.

// Comment
-(void)viewWillAppear:(BOOL)animated;
{
 [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.topItem.title = @"Contact";
    
    // create a toolbar to have two buttons in the right
    UICustomToolbar* tools = [[UICustomToolbar alloc] initWithFrame:CGRectMake(0.0, 0.0, 113.0, 44.01)]; 
    
    tools.alpha = 0.5;
    
    [tools setBarStyle: UIBarStyleBlackTranslucent];
    
    [tools setTranslucent: YES];
    
    [tools setTintColor: self.navigationController.navigationBar.tintColor];
    
    // create the array to hold the buttons, which then gets added to the toolbar
    NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];

    UIBarButtonItem *callUs =  [[UIBarButtonItem alloc] initWithTitle:@"Call"
                                                                style:UIBarButtonItemStylePlain
                                                               target:self
                                                               action:@selector(dial:)];
    
    callUs.style = UIBarButtonItemStyleBordered;
    
    [buttons addObject:callUs];
    [callUs release];
    
    // create a standard "send" button
    UIBarButtonItem *send =  [[UIBarButtonItem alloc] initWithTitle:@"Send"
                                                              style:UIBarButtonItemStylePlain
                                                             target:self
                                                             action:@selector(send:)];
    
    send.style = UIBarButtonItemStyleBordered;
    
    [buttons addObject: send];
    [send release];
    
    // stick the buttons in the toolbar
    [tools setItems:buttons animated:NO];
    
    [buttons release];
    
    // and put the toolbar in the nav bar
    self.navigationController.navigationBar.topItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
    [tools release];