原创 Saving a file with a new type

- (void)exportDocument:(NSString*)name toType:(NSString*)typeUTI { NSWindow* window = [[[self windowController

原创 Reading the contents of a file using POSIX functions

- (NSData*)readDataFromFileAtURL:(NSURL*)anURL { NSString* filePath = [anURL path]; fd = open([filePath UTF8Str

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

- (NSURL*)applicationDirectory { NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier]; NSFileMa

原创 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_sema

原创 Adding a Single Task to a Queue

The following example shows how to use the block-based variants for dispatching tasks asynchronously and synchronous

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

Executing a completion callback after a task : void average_async(int *data, size_t len, dispatch_queue_t queue,

原创 Filters Limit the File Types That the User Can Select

- (IBAction)askUserForImage:(id)sender { NSOpenPanel* panel = [NSOpenPanel openPanel]; // Let the user select

原创 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 pat

原创 iOS Reverse Engineering Resources

http://samdmarshall.com/re.html 轉載地址: http://blog.csdn.net/forlong401/article/details/23482619 Reverse Enginee

原创 Creating an NSInvocationOperation Object / NSBlockOperation Object

@implementation MyCustomClass - (NSOperation*)taskWithData:(id)data { NSInvocationOperation* theOp = [[NSInvocationOp

原创 Looking for files that have been modified recently

NSString *directoryPath = <#Get a path to a directory#>; NSDirectoryEnumerator *directoryEnumerator = [[NSFileManager d

原创 Retrieving the list of items in a directory all at once

NSURL *url = <#A URL for a directory#>; NSError *error = nil; NSArray *properties = [NSArray arrayWithObjects: NSURLLoc

原创 Reading the contents of a file using NSFileHandle

- (NSData*)readDataFromFileAtURL:(NSURL*)anURL { NSFileHandle* aHandle = [NSFileHandle fileHandleForReadingFromURL:

原创 Presenting the open panel to the user

- (IBAction)openExistingDocument:(id)sender { NSOpenPanel* panel = [NSOpenPanel openPanel]; // This method displa

原创 Performing Loop Iterations Concurrently

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