Tôi đang tạo một ứng dụng iOS hiển thị bộ hẹn giờ. Tôi không nghĩ rằng tôi có thể giữ cho bộ đếm thời gian chạy sau khi người dùng nhấn nút home, vì vậy tôi muốn ghi lại thời gian khi người dùng thoát ứng dụng và sử dụng thời gian khi họ nhập lại ứng dụng để cập nhật bộ hẹn giờ. Đây là mã tôi đã cố gắng:Biểu tượng không xác định cho lỗi biên dịch i386 kiến trúc do 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.
*/
}
(nếu tôi nhận xét ra khỏi cơ thể phương pháp applicationWillResignActive nó xây dựng tốt)
Đây là lỗi tôi nhận được vào biên dịch
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)
Tôi nghĩ lỗi liên quan đến việc không nhập đúng khung, vì vậy tôi đã thử nhập
#import <QuartzCore/CoreAnimation.h>
vào tệp tiêu đề AppDelegate của tôi, nhưng điều này cũng không hoạt động.
Tôi đang sử dụng CACurrentMediaTime() vì từ những gì tôi đã đọc, NSDate phụ thuộc vào mạng và do đó sẽ không từ bỏ các khoảng thời gian chính xác vì nó đã được sử dụng lần cuối