2011-12-18 17 views
15

estoy haciendo una aplicación para iOS que muestra un temporizador. No creo que pueda mantener el temporizador encendido después de que el usuario presiona el botón de inicio, por lo que quiero registrar el tiempo cuando el usuario sale de la aplicación, y usar el tiempo cuando vuelven a ingresar a la aplicación para actualizar el temporizador. Este es el código Traté:símbolo Indefinido de error de compilación arquitectura i386 causada por CACurrentMediaTime()

- (void)applicationWillResignActive:(UIApplication *)application 
{ 
    double currentTime = CACurrentMediaTime(); 
    NSLog(@"%g", currentTime); 
    /* 
    Sent when the application is about to move from active to inactive state. This can  occur for certain types of temporary interruptions (such as an incoming phone call or SMS  message) or when the user quits the application and it begins the transition to the background state. 
    Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 
    */ 
} 

(si comento hacia fuera del cuerpo del método applicationWillResignActive se construye muy bien)

Este es el error que estoy siguiendo compilación

Ld /Users/Max/Library/Developer/Xcode/DerivedData/ImpromptuTimer-cbcnsujnixygrxfhtvkovhnpqamb/Build/Products/Debug-iphonesimulator/ImpromptuTimer.app/ImpromptuTimer normal i386 cd /Users/Max/Developer/ImpromptuTimer setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/Max/Library/Developer/Xcode/DerivedData/ImpromptuTimer-cbcnsujnixygrxfhtvkovhnpqamb/Build/Products/Debug-iphonesimulator -F/Users/Max/Library/Developer/Xcode/DerivedData/ImpromptuTimer-cbcnsujnixygrxfhtvkovhnpqamb/Build/Products/Debug-iphonesimulator -filelist /Users/Max/Library/Developer/Xcode/DerivedData/ImpromptuTimer-cbcnsujnixygrxfhtvkovhnpqamb/Build/Intermediates/ImpromptuTimer.build/Debug-iphonesimulator/ImpromptuTimer.build/Objects-normal/i386/ImpromptuTimer.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/Max/Library/Developer/Xcode/DerivedData/ImpromptuTimer-cbcnsujnixygrxfhtvkovhnpqamb/Build/Products/Debug-iphonesimulator/ImpromptuTimer.app/ImpromptuTimer

Undefined symbols for architecture i386: "_CACurrentMediaTime", referenced from: -[ImpromptuTimerAppDelegate applicationWillResignActive:] in ImpromptuTimerAppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

pienso el error está relacionado con la no importación de los marcos correctos, así que traté de importar

#import <QuartzCore/CoreAnimation.h> 

en mi archivo de cabecera de mi AppDelegate, pero esto tampoco funcionó.

estoy usando CACurrentMediaTime() porque por lo que he leído, NSDate depende de la red y por lo tanto no dará intervalos de tiempo exactos desde que se utilizó por última vez

Respuesta

31

Es necesario vincular QuartzCore.framework. Ahí es donde CACurrentMediaTime proviene de: http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/CoreAnimation_functions/Reference/reference.html

Consulte este documento sobre cómo agregar marcos: https://developer.apple.com/library/ios/#recipes/xcode_help-project_editor/Articles/AddingaLibrarytoaTarget.html#//apple_ref/doc/uid/TP40010155-CH17-SW1

de edición: Para aclarar, mientras estás en lo correcto en la necesidad de incluir/QuartzCore importación, también hay que enlazar con eso, que está relacionado, pero diferente. Ver Compiling and Linking

4

simplemente añadiendo QuartzCore.framework resuelto.

Cuestiones relacionadas