problem running accelerometer on device

Discussion in 'iOS Programming' started by medasmx, Oct 2, 2010.

  1. medasmx macrumors member

    Nov 9, 2008
    When I try to use an accelerometer program from the Big Nerd Ranch, iPhone book, on my iPhone device, I get the following error...

    program received signal: "SIGABRT"
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIWindow setRootViewController:]: unrecognized selector sent to instance 0x118fe0'

    The code is from Chapter 8 in the iPhone Big Nerd Ranch book. I have an old iPhone. My OS is 3.1.3 (bought phone in 2007). This program works fine on the simulator, but the accelerometer has no function on the simulator.

    Below is the additional code added from a project that was essentially 2 views with a tab bar.

    	[super viewWillAppear:animated];
    	NSLog(@"Monitoring accelerometer");
    	UIAccelerometer*a=[UIAccelerometer sharedAccelerometer];
    	[a setUpdateInterval:0.1];
    	[a setDelegate:self];
    	[super viewWillDisappear:animated];
    	[[UIAccelerometer sharedAccelerometer]setDelegate:nil];
    	HypnosisView*hv=(HypnosisView*)[self view];
    	[hv setXShift:10.0*[accel x]];
    	[hv setYShift:10.0*[accel y]];
    	[hv setNeedsDisplay];
    Any help is appreciated. Thanks.

  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    Somewhere your memory management is messed up and you have ended up with a pointer to an object that you expected to be one type but it's another (most likely you failed to retain an object you should have or you released one you should not have).

Share This Page