Skip to content

Commit

Permalink
Fixed memory leaks, uninitialised variables, display format, deprecat…
Browse files Browse the repository at this point in the history
…ed methods & other basic fixes.
  • Loading branch information
kpmaalej committed Mar 22, 2011
1 parent 6674536 commit 27f8267
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 25 deletions.
4 changes: 2 additions & 2 deletions ARKit/ARGeoCoordinate.m
Expand Up @@ -33,7 +33,7 @@ - (void)calibrateUsingOrigin:(CLLocation *)origin {
if (![self geoLocation])
return;

double baseDistance = [origin getDistanceFrom:[self geoLocation]];
double baseDistance = [origin distanceFromLocation:[self geoLocation]];
[self setRadialDistance: sqrt(pow([origin altitude] - [[self geoLocation] altitude], 2) + pow(baseDistance, 2))];

float angle = sin(ABS([origin altitude] - [[self geoLocation] altitude]) / [self radialDistance]);
Expand All @@ -44,7 +44,7 @@ - (void)calibrateUsingOrigin:(CLLocation *)origin {
[self setInclination: angle];
[self setAzimuth: [self angleFromCoordinate:[origin coordinate] toCoordinate:[[self geoLocation] coordinate]]];

NSLog(@"distance is %d, angle is %d, azimuth is %d",baseDistance,angle,[self azimuth]);
NSLog(@"distance is %f, angle is %f, azimuth is %f",baseDistance,angle,[self azimuth]);
}

+ (ARGeoCoordinate *)coordinateWithLocation:(CLLocation *)location locationTitle:(NSString *) titleOfLocation {
Expand Down
5 changes: 1 addition & 4 deletions ARKit/ARKit.m
Expand Up @@ -19,12 +19,9 @@ +(BOOL)deviceSupportsAR{
}

//Detect compass, if not there, return NO
CLLocationManager *locMan = [[CLLocationManager alloc] init];
if(!locMan.headingAvailable){
[locMan release];
if(![CLLocationManager headingAvailable]){
return NO;
}
[locMan release];

//cannot detect presence of GPS
//I could look at location accuracy, but the GPS takes too long to
Expand Down
24 changes: 6 additions & 18 deletions ARKitDemo/ARKitDemo.xcodeproj/project.pbxproj
Expand Up @@ -267,13 +267,9 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = ARKitDemo_Prefix.pch;
HEADER_SEARCH_PATHS = ../iPhoneAugmentedRealityLib;
HEADER_SEARCH_PATHS = ../ARKit;
INFOPLIST_FILE = "ARKitDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\\\"$(SRCROOT)/../iPhoneAugmentedRealityLib/build/Debug-iphoneos\\\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = ARKitDemo;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
Expand All @@ -287,13 +283,9 @@
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = ARKitDemo_Prefix.pch;
HEADER_SEARCH_PATHS = ../iPhoneAugmentedRealityLib;
HEADER_SEARCH_PATHS = ../ARKit;
INFOPLIST_FILE = "ARKitDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\\\"$(SRCROOT)/../iPhoneAugmentedRealityLib/build/Debug-iphoneos\\\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = ARKitDemo;
};
Expand All @@ -302,7 +294,7 @@
696B955F1116ADDB007D7A0F /* Distribution */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
GCC_AUTO_VECTORIZATION = YES;
GCC_C_LANGUAGE_STANDARD = c99;
Expand All @@ -322,13 +314,9 @@
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = ARKitDemo_Prefix.pch;
HEADER_SEARCH_PATHS = ../iPhoneAugmentedRealityLib;
HEADER_SEARCH_PATHS = ../ARKit;
INFOPLIST_FILE = "ARKitDemo-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\\\"$(SRCROOT)/../iPhoneAugmentedRealityLib/build/Debug-iphoneos\\\"",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = ARKitDemo;
};
Expand All @@ -337,7 +325,7 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvmgcc42;
Expand All @@ -352,7 +340,7 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_AUTO_VECTORIZATION = YES;
GCC_C_LANGUAGE_STANDARD = c99;
Expand Down
4 changes: 3 additions & 1 deletion ARKitDemo/Classes/ARKitDemoAppDelegate.m
Expand Up @@ -17,6 +17,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
if([ARKit deviceSupportsAR]){
ARViewController *viewController = [[ARViewController alloc] initWithDelegate:self];
[window addSubview:[viewController view]];
[viewController release];
}
else{
UIViewController *viewController = [[UIViewController alloc] init];
Expand All @@ -27,6 +28,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
errorLabel.textAlignment = UITextAlignmentCenter;
[viewController.view addSubview:errorLabel];
[window addSubview:[viewController view]];
[viewController release];
}

[window makeKeyAndVisible];
Expand All @@ -40,7 +42,7 @@ - (void)dealloc {

-(NSMutableArray *)getLocations {

NSMutableArray *locationArray;
NSMutableArray *locationArray = [[[NSMutableArray alloc] init] autorelease];
ARGeoCoordinate *tempCoordinate;
CLLocation *tempLocation;

Expand Down

0 comments on commit 27f8267

Please sign in to comment.