笔记:
获取设备充电状态:
UIDeviceBatteryState: The battery power state of the device.
typedef enum {
UIDeviceBatteryStateUnknown,
UIDeviceBatteryStateUnplugged,
UIDeviceBatteryStateCharging,
UIDeviceBatteryStateFull,
} UIDeviceBatteryState;UIDeviceBatteryStateUnknown: The battery state for the device cannot be determined.
UIDeviceBatteryStateUnplugged: The device is not plugged into power; the battery is losing power.
UIDeviceBatteryStateCharging: The device is plugged into power and the battery is less than 100% charged.
UIDeviceBatteryStateFull: The device is plugged into power and the battery is 100% charged.
//code
UIDeviceBatteryState batteryState = [UIDevice currentDevice].batteryState;
if (batteryState = UIDeviceBatteryStateCharging || batteryState = UIDeviceBatteryStateFull)
{
//it's charging
}
获取设备freeSpace
-(unsigned)getFreeDiskspacePrivate {
NSDictionary *atDict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:@"/" error:NULL];
unsigned freeSpace = [[atDict objectForKey:NSFileSystemFreeSize] unsignedIntValue];
NSLog(@"%s - Free Diskspace: %u bytes - %u MiB", __PRETTY_FUNCTION__, freeSpace, (freeSpace/1024)/1024);
return freeSpace;
}
-(uint64_t)getFreeDiskspace {
uint64_t totalSpace = 0;
uint64_t totalFreeSpace = 0;
NSError *error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];
if (dictionary) {
NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];
NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
NSLog(@"Memory Capacity of %llu MiB with %llu MiB Free memory available.", ((totalSpace/1024ll)/1024ll), ((totalFreeSpace/1024ll)/1024ll));
} else {
NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %ld", [error domain], (long)[error code]);
}
return totalFreeSpace;
}
//多个应用共享数据
Handling URL Requests
An app that has its own custom URL scheme must be able to handle URLs passed to it. All URLs are passed to your app delegate, either at launch time or while your app is running or in the background. To handle incoming URLs, your delegate should implement the following methods:
Use the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods to retrieve information about the URL and decide whether you want to open it. If either method returns NO, your app’s URL handling code is not called.
In iOS 4.2 and later, use the application:openURL:sourceApplication:annotation: method to open the file.
If your app is not running when a URL request arrives, it is launched and moved to the foreground so that it can open the URL. The implementation of your application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: method should retrieve the URL from its options dictionary and determine whether the app can open it. If it can, return YES and let your application:openURL:sourceApplication:annotation: (or application:handleOpenURL:) method handle the actual opening of the URL. (If you implement both methods, both must return YES before the URL can be opened.) Figure 6-1 shows the modified launch sequence for an app that is asked to open a URL.
苹果官方文档地址:https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW50
一篇文章:
http://kotikan.com/blog/posts/2011/3/passing-data-between-ios-apps
//在一个app中打开另外一个app
首先需要创建该app的Custom Url Scheme
Launching iPhone Apps With Custom URL Scheme
国外大牛的文章:
http://iosdevelopertips.com/cocoa/launching-other-apps-within-an-iphone-application.html
http://iosdevelopertips.com/cocoa/launching-other-apps-within-an-iphone-application.html
SQLite创建触发器的基本语法如下:
CREATE TRIGGER trigger_name [BEFORE|AFTER] event_name
ON table_name
BEGIN
-- Trigger logic goes here....
END;
在这里,event_name 可能是INSERT,DELETE和UPDATE操作所提到的表table_name数据库。您可以选择指定FOR EACH ROW表名后。
以下是语法上创建一个触发器UPDATE操作一个或多个指定一个表列如下:
CREATE TRIGGER trigger_name [BEFORE|AFTER] UPDATE OF column_name
ON table_name
BEGIN
-- Trigger logic goes here....
END;
易白教程:http://www.yiibai.com/sqlite/sqlite_triggers.html