Tuesday, 12 March 2013

Nice simple bit of Gyro code

 - (void)viewDidLoad
{
    [super viewDidLoad];
    
    _manager = [[CMMotionManager alloc]init];
    _manager.gyroUpdateInterval = 0.1;
    
    NSOperationQueue *queue = [NSOperationQueue mainQueue];
    
    void (^handler)(CMGyroData *data, NSError *error) = ^(CMGyroData *data, NSError *error){
        _lblX.text = [NSString stringWithFormat:@"%f", data.rotationRate.x];
        _lblY.text = [NSString stringWithFormat:@"%f", data.rotationRate.y];
        _lblZ.text = [NSString stringWithFormat:@"%f", data.rotationRate.z];
    };
    
    [_manager startGyroUpdatesToQueue:queue withHandler:handler];
    
    
}

Wednesday, 4 July 2012

Top Tip

How many times have you had to do something like this

int count = [NSArray count]
count--;

to allow for the 0 index?

i.e if it has a count of 3 it actually contains index 0,1,2

try using this instead

#define minus(x)(x - 1)

[array objectAtIndex:minus(count)];

saves times and lines.

Tuesday, 3 July 2012

Notification Centre Drop Down, What a Nightmare

Nightmare might be a bit strong, but under certain circumstances it can prove to be one. 

"I can't switch it off"

The main problem is, I am unable to switch it off. I have an app which uses swipe gestures for interaction. More than once now the Notification Centre has dropped down whilst I'm in the middle of using the app. What makes this worse is the fact that the app is a test and by this NC fault it invalidates the data.

The Answer

There is accessibility support commingling in iOS 6, however since we have a load of iPad(1) (which won't run the new version of the operating system), this option isn't available to us.

Come on apple, give us a way to switch this off - please!

Monday, 11 June 2012

preventing a race condition when using two TapRecognizers

I recently had a problem where I had a single tap recogniser and a double tap recogniser. The problem was when someone performed a double tap, the app was also detecting a single tap.

Luckily there is a really easy solution to this.

Stack Overflow Question

Tuesday, 29 May 2012

Prototyping

Yes prototyping is on the agenda today.

I am yet to come across a good system for prototyping iOS apps. I have seen several apps that allow you to make mock up interfaces; but not a single one provides quite the level I require, in fact its a bit disappointing. All of the prototyping apps I have come across seem very simplistic and smart looking, but provide little depth when it comes to functionality. Really what I would like is a prototyping program that allows you to add your own scrip, for modifying the interaction. If any one is reading this and thinking "I know one such app" please post a comment and ill check it out.

I am now looking at new possibilities of prototyping. I even considering looking into flash player, but I think that might be going to far the other way. ATM I have been writing the prototypes in Objective C. The problem is, its just too lengthy a process.

If I find a prototyping app that provides high level functionality, ill let you know.

Thursday, 15 March 2012

NSValue

Top Tip

Using NSValue to wrap c types saves time and energy when it comes to debugging.

CGPoint point;

NSValue *val = [NSValue valueWithCGPoint:point];

CGPoint returnPoint

[val GetValue:&returnPoint];