nsfilehandle

Use NSFilehandle to serial-port communication ,why don't receive NSFilehandle's notification .

my source-code as belowed : a part of source-code as belowed : - (id)init { NSFileHandle *fh =[[NSFileHandle alloc] initWithFileDescriptor:myfileDescriptor closeOnDealloc:YES]; NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self selector: @selector(getData:) ...

in cocoa,Aout serial communiction using nsfilehandle issues .

i have a software about serial communication , it to be develop in MAC os=10.5.8 using cocoa 's nsfilehandle , test ok , but when MAC os upgrading to 10.6 ,the program work no normal, can't receive nsfilehandle's notification . it's why , ...

NSFileHandle weird problem with iphone

Hi , i am downloading an mp3 file using NSURLConnection and saving it to a file . The problem is mp3 file is created (found the mp3 file created when using simulator), but i cannot access the mp3 file . Any ideas?!!!!! This is the code i'm using filename = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMas...

Send more than 32768 Bytes at once from one TCP-Socket to an other

Hey guys, I don't know if this question has been asked yet but imagine following situation: I have two TCP-Sockets (opened with NSSocketPort und listening with two NSFileHandle) and now I want to send some NSData between them. @try { [fileHandle writeData:data]; } @catch (NSException * e) { // Do some alert } Everything is ri...

How to download a wav file from the web to a location on iPhone using NSFileHandle and NSURLConnection?

Hi all, I want to download a wav file from a web service, cache it on the iphone and playback it using AVAudioPlayer. Using NSFileHandle and NSURLConnection seems a viable solution when dealing with relatively large files. However, after running the app in the simulator I don't see any saved file under the defined directory (NSHomeDirect...

Writing to a new line of a file in Objective-C

For some strange reason, the \n and \r escape sequences do not seem to be working in my code. I want to write each NSString on a new line of the file, but it just appends it the last string on one line. Here's the code: for (Entry *entry in self.entries) { NSString *path = @"/Users/me/File.txt"; NSString *string = (@"%@\r\n", ...

Is it possible to search files of particular extension in the entire device ?

In my application, i am trying to find all files of particular extension (like .pdf, .txt, etc) that are stored in the device (either downloaded or transferred from system) and want to list them in table View. Is it possible to do so and if it is then can i associate file of specific extension to get it open in supporting application (an...

iphone charset howto

Hi all, i've a class (downloaded from internet) that read a value of a file in this way (and after split the file): NSArray* array = [fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; where fileContents is my fullpathoffile. in which way i must write my string? i'm trying with thi...

Sending large amounts of data with NSFileHandle

So I'm using Apple's PictureSharing/PictureSharingBrowser samples to send and receive data. This uses an NSFileHandle on the server side to send a picture using NSFileHandle's writeData method. NSFileHandle * incomingConnection = [[aNotification userInfo] objectForKey:NSFileHandleNotificationFileHandleItem]; [[aNotification object] acc...

NSFileHandle for binary files ?

How can we read executable files in memory and then manipulate them , does NSFileHandle can works with executable files and how so ?! Thank you. ...

iPhone OS 4.0: NSFileHandleDataAvailableNotification not providing callback at file-end

I'm a bit new to iPhone development, so be gentle! I'm supporting an app which loads a wav file from a URL file-stream, and plays it back through an AudioQueue. We run a continual loop in another thread, and stop the Queue if we detect that it has no buffers in use, and the input FileStream has reached its end. In turn, we detect if th...

Optimize memory consumption when gradually writing to a file

Hi! I've been doing some tests, and one of my needs is to read data from different xml files and stack it together on a single file. While I've managed to accomplish this, memory consumption seems to be quite large for the task, the iphone simulator didn't even raise the memory warning, but I don't think the real iPhone would tolerate th...

Cocoa Createfileapath

hello, I am trying to create a file on mac os. the data from the file will be accessed by the app. but how to create a file having read permission on all accounts. Currently the app can read data in admin account only. I am using following syntax: BOOL B = [fm createFileAtPath:p1 contents:data attributes:nil]; is it something to do w...

NSFileHandle fileHandleForWritingAtPath: return null!!

Hi, my iPad app has a small download facility, for which I want to append the data using an NSFileHandle. The problem is the creation call only returns null file handles. What could be the problem? Here is the three lines of code that are supposed to create my file handle: NSString *applicationDocumentsDirectory = [NSSearchPathForDirec...

How to read data from NSFileHandle line by line?

I have a text file having data as given e.g. PUFGUjVRallYZDNaazFtVjVObU1zWm5ZcUJUYU5ORk4zbGthNHNDVUdSMlFVQmpSVEoxUUNSallYaFhkanBITXBGR1NTQnpZRTltZE1OalVzSkdXQ0Z6WXR0V2RpTmpTdXgwTWs5V1lZSkZiWjFXT29OV2JSVlhaSTUwYUpwR040UUZXTzVHVXFoWFVRcFdWNHdVTUJ0Q1VHSmxXVlJVTlJCMVE1VTFWV PUFGUjVRallYZDNaazFtVjVObU1zWm5ZcUJUYU5ORk4zbGthNHNDVUdSMlFVQmpSV...

Xcode app version not compatible with Mac OS X version

am using Os X 10.6.4 and X code Version 3.2.3 for developing some simple app files and using PackageMaker to distribute these app files. But when trying to run the package on some other mac I am getting error that the package is not compatible with the Os X its running and file would not be installed. Is this a problem with X code or pac...

Base64 Encode File Using NSData Chunks

Update 4 Per Greg's suggestion I've created one pair of image/text that shows the output from a 37k image to base64 encoded, using 100k chunks. Since the file is only 37k it's safe to say the loop only iterated once, so nothing was appended. The other pair shows the output from the same 37k image to base64 encoded, using 10k chunks. Sinc...

NSFileHandle fileHandleForReadingFromURL can someone explain this to me please?

I am trying to make a customized input stream based off of the one by Dave DeLong here that also allows for reading data from a server via NSURL. So far, I have this approach, which works fine for local files: @interface RJRStreamReader : NSObject { @private NSFileHandle *fileHandle; NSStringEncoding encoding; NSString *...

What are Sockets, Pipes and Devices?

I'm studying the Low-Level File Management Programming Topics from Apple. In the NSFileHandle section, they say: The scope of NSFileHandle is not limited to files. It provides the only Foundation object that can read and write to communications channels such as those implemented by sockets, pipes, and devices. That sounds...

Difference between -fileHandleForWritingAtPath: and fileHandleForUpdatingAtPath: ?

For me it sounds like the same thing. Updating a file implies to write to the file. Writing to a file is also an update for me. But I guess there's a subtle difference ;-) Does anyone know? ...