I am having a really weird problem because i get completely different results between testing my program WHILE connected to the computer (trough xcode) but ON my device. and just taping the icon while not being plugged to xcode. (I think it might be coordinate issues).
So i was thinking there might be a difference between testing in these 2 ways.
Sorry i forgot to specify, I used to get the same results in both ways but then i created a singleton for my location manager instead of creating a single location manager object in each window.
This is how i am creating the Header:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
// protocol for sending location updates to another view controller
@protocol LocationManagerDelegate <NSObject>
@required
- (void)locationUpdate:(CLLocation*)location;
@end
@interface LocationManagerSingleton : NSObject <CLLocationManagerDelegate> {
CLLocationManager* locationManager;
CLLocation* location;
//id delegate;
}
@property (nonatomic, retain) CLLocationManager* locationManager;
@property (nonatomic, retain) CLLocation* location;
@property (nonatomic, assign) id <LocationManagerDelegate> delegate;
+ (LocationManagerSingleton*) sharedInstance; // Singleton method
@end
and this is the implementation:
#import "LocationManagerSingleton.h"
//static LocationManagerSingleton* sharedCLDelegate = nil;
@implementation LocationManagerSingleton
@synthesize locationManager, location, delegate;
#pragma mark - Singleton Methods -
+ (LocationManagerSingleton*)sharedInstance {
static LocationManagerSingleton *_sharedInstance;
if(!_sharedInstance) {
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedInstance = [[super allocWithZone:nil] init];
});
}
return _sharedInstance;
}
+ (id)allocWithZone:(NSZone *)zone {
return [self sharedInstance];
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
#if (!__has_feature(objc_arc))
- (id)retain {
return self;
}
- (unsigned)retainCount {
return UINT_MAX; //denotes an object that cannot be released
}
- (void)release {
//do nothing
}
- (id)autorelease {
return self;
}
#endif
#pragma mark - Custom Methods -
// Add your custom methods here
- (id)init
{
self = [super init];
if (self != nil) {
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
self.locationManager.distanceFilter = 5;
self.locationManager.purpose = @"This app uses your location for Augmented Reality";
[self.locationManager startUpdatingLocation];
[self.locationManager startUpdatingHeading];
NSLog(@"LocationManager initialized with accuracy best for Navigation");
NSLog(@"CUrrent Latitude: %f, Current Longitude: %f",locationManager.location.coordinate.latitude,locationManager.location.coordinate.longitude);
}
return self;
}
#pragma mark - CLLocationManagerDelegate Methods -
- (void)locationManager:(CLLocationManager*)manager
didUpdateToLocation:(CLLocation*)newLocation
fromLocation:(CLLocation*)oldLocation
{
/*…some filer method to check if the new location is good …*/
bool good = YES;
if (good)
{
[self.delegate locationUpdate:newLocation];
}
//self.location = newLocation;
//NSLog(@"Updated: %@",newLocation);
}
- (void)locationManager:(CLLocationManager*)manager
didFailWithError:(NSError*)error
{
/* ... */
}
@end
Okay it seems that OpenGL was causing the problem. My theory was that since a pointer variable used for texturing was inside a loop when the localization manager updated and redraw this variable would get messed up because it was being reinitialized everyrun but the value wouldnt be set to 0, and since opengl has the pointer to the adress not to the pointer it would read corrupted data (since the loop might have updated that space until opengl was told the new adress of the variable). Still i have no idea why it worked perfectly while hooked up to the computer and not by itself.