Presenting a local notification immediately while running in the background

- (void)applicationDidEnterBackground:(UIApplication *)application { NSLog(@"Application entered background state."); // bgTask...

2014-08-30 19:40:32

阅读数 651

评论数 0

Creating, configuring, and scheduling a local notification

- (void)scheduleNotificationWithItem:(ToDoItem *)item interval:(int)minutesBefore { NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalend...

2014-08-30 19:34:09

阅读数 633

评论数 0

Monitoring the death of a parent process (via Dispatch Sources)

void MonitorParentProcess() { pid_t parentPID = getppid(); dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_D...

2014-08-29 17:20:45

阅读数 473

评论数 0

Installing a block to monitor signals (via Dispatch Sources)

void InstallSignalHandler() { // Make sure the signal does not terminate the application. signal(SIGHUP, SIG_IGN); dispatch_queue_t ...

2014-08-29 17:09:13

阅读数 650

评论数 0

Watching for filename changes (via Dispatch Sources)

an example that monitors a file for name changes and performs some custom behavior whenit does. (You would provide the actual behavior in place of th...

2014-08-29 16:57:12

阅读数 608

评论数 0

Reading /(Writing) Data from / (to) a Descriptor (Dispatch Sources)

dispatch_source_t ProcessContentsOfFile(const char* filename) { // Prepare the file for reading. int fd = open(filename, O_RDONLY); ...

2014-08-29 16:47:58

阅读数 450

评论数 0

Getting data from a dispatch source

Function Description dispatch_source_-get_handle This function returns the underlying system data type tha...

2014-08-29 16:18:42

阅读数 390

评论数 0

Creating a timer dispatch source

dispatch_source_t CreateDispatchTimer(uint64_t interval, uint64_t leeway, dispatch_queue_t queue, dis...

2014-08-29 16:17:45

阅读数 1124

评论数 0

Dispatch Sources

About Dispatch Sources A dispatch source is a fundamental data type that coordinates the processing of specific low-level systemevents. Grand Centr...

2014-08-29 15:21:49

阅读数 469

评论数 0

Waiting on Groups of Queued Tasks (dispatch_group_async)

// Waiting on asynchronous tasks  dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_group_t group =...

2014-08-29 14:47:45

阅读数 715

评论数 0

Using Dispatch Semaphores to Regulate the Use of Finite Resources

The semantics for using a dispatch semaphore are as follows: When you create the semaphore (using the dispatch_semaphore_create function), you...

2014-08-29 14:42:29

阅读数 557

评论数 0

Performing Loop Iterations Concurrently

Original: for (i = 0; i < count; i++) { printf("%u\n",i); } Replacement: dispatch_queue_t queue = dispatch_get_global_queue(DI...

2014-08-29 14:37:38

阅读数 380

评论数 0

Performing a Completion Block When a Task Is Done (!!!)

Executing a completion callback after a task

2014-08-29 14:03:15

阅读数 513

评论数 0

Adding a Single Task to a Queue

The following example shows how to use the block-based variants for dispatching tasks asynchronously and synchronously:  dispatch_queue_t myCustomQu...

2014-08-29 13:59:02

阅读数 345

评论数 0

Storing Custom Context Information with a Queue

Storing Custom Context Information with a Queue All dispatch objects (including dispatch queues) allow you to associate custom context data with the...

2014-08-29 13:52:19

阅读数 471

评论数 0

Creating an NSInvocationOperation Object / NSBlockOperation Object

@implementation MyCustomClass - (NSOperation*)taskWithData:(id)data { NSInvocationOperation* theOp = [[NSInvocationOperation alloc] initWithTarget:...

2014-08-29 10:09:28

阅读数 463

评论数 0

Reading the contents of a file using POSIX functions

- (NSData*)readDataFromFileAtURL:(NSURL*)anURL { NSString* filePath = [anURL path]; fd = open([filePath UTF8String], O_RDONLY); if (fd ==...

2014-08-28 15:12:58

阅读数 586

评论数 0

Reading the contents of a file using NSFileHandle

- (NSData*)readDataFromFileAtURL:(NSURL*)anURL { NSFileHandle* aHandle = [NSFileHandle fileHandleForReadingFromURL:anURL error:nil]; NSData* ...

2014-08-28 14:57:51

阅读数 929

评论数 0

Reading the bytes from a text file using a dispatch I/O channel

- (void)readContentsOfFile:(NSURL*)anURL { // Open the channel for reading. NSString* filePath = [anURL path]; self.channel = dispat...

2014-08-28 14:42:43

阅读数 1006

评论数 0

How to create a custom directory for app files inside the ~/Library/Application Support directory.

- (NSURL*)applicationDirectory { NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier]; Managing Files and Directories Creating New...

2014-08-28 14:03:35

阅读数 814

评论数 0

提示
确定要删除当前文章?
取消 删除
关闭
关闭