Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating files in Objective-C

Which one of these 2 cases is faster in creating files?

Case 1:
======
NSData *data = [Some data];
[data writeToFile:filePath atomically:YES];

Case 2:
=======
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:filePath  contents:data attributes:nil];

Thanks Biranchi.

like image 772
Biranchi Avatar asked Nov 10 '09 10:11

Biranchi


People also ask

How do I write to a file in Objective-C?

Having stored the contents of a file in an NSData object, that data may subsequently be written out to a new file using the createFileAtPath method: databuffer = [filemgr contentsAtPath: @"/tmp/myfile. txt" ]; [filemgr createFileAtPath: @"/tmp/newfile. txt" contents: databuffer attributes: nil];

How do you create a file objective?

To request creation of a new fileRight click the parent folder that will contain the new file. 2. Select New > Add File to open the Add File to Objective window.

What is .a file in Objective-C?

A . a file is a compiled static library file (aka archive). It does not contain any source code, only object code for one or more architectures.

How to create NSObject Class in Objective-C?

Creating a Custom ClassGo ahead an choose “Objective-C class” and hit Next. For the class name, enter “Person.” Make it a subclass of NSObject. NSObject is the base class for all objects in Apple's developer environment. It provides basic properties and functions for memory management and allocation.


1 Answers

Why are you worrying about this... Are you going to be writing data frequently.. at like 60 FPS ?.. or 60 SPS (Saves per second) :D

Use any of the above

like image 72
Rajavanya Subramaniyan Avatar answered Oct 26 '22 23:10

Rajavanya Subramaniyan