iphone provisioning hell

May, 9 -- Categories: Objective-C

After googling and trying every solution in excruciating detail none worked. I’m completely convinced the error was related to rebuilding the app with the same name. The first version was already provisioned and running without problem on my phone, if this isn’t your problem then this won’t work for you. But if it is then try it, it worked for me.

Take your .xcodeproj, .pch, main.m, class and .xib files (note not the build directory, not that I’m sure that matters) and dump them in the directory of the provisioned app, Build > Clean All Targets and poof…. it worked.

Here are some of the urls that I tried:

http://vehera.jsn-server7.com/jana/blog/?p=141

http://blog.besiex.com/?p=45

http://iphoneincubator.com/blog/general/your-mobile-device-has-encountered-an-unexpected-error-0xe800003a

http://discussions.apple.com/thread.jspa?threadID=1833723&tstart=0

http://www.24100.net/2009/02/iphone-sdk-mobile-provisioning-0xe800003a-0xe8000001/

iphone movement alarm code

May, 6 -- Categories: Objective-C

.h file

// sensitivity level, 1.0 was way too sensitive 1.1 not enough
#define kAccelerationThreshold 1.07
#define kUpdateInterval (1.0f/10.0f)

@interface MainViewController : UIViewController <UIAccelerometerDelegate> {

.m file

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {

if (fabsf(acceleration.x) > kAccelerationThreshold ||
fabsf(acceleration.y) > kAccelerationThreshold ||
fabsf(acceleration.z) > kAccelerationThreshold ) {

// whatever needs to happen here in this case select a sound and then play it
[self playSound: [self getSelectedSound] ];

}

}

this went in the - (void)viewDidLoad {

UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = kUpdateInterval;

Opening a url in Safari

May, 4 -- Categories: Objective-C

Here it is:

NSString* urlString = [NSString stringWithFormat:@"http://www.tldomain.com/"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

iphone random numbers

May, 3 -- Categories: Objective-C

In researching random number generation there seems to be alot of discussion as to the best way to go. These are the two ways I consider:

int generated = arc4random() % 10;
generated will be an integer between 0 and 10.

or

srandom( time(NULL) );
int generated = ( random() % 10 );