Sunday, May 12, 2013

NSInputStream initWithURL example ios


initWithURL:

Initializes and returns an NSInputStream object that reads data from the file at a given URL.
- (id)initWithURL:(NSURL *)url
Parameters
url
The URL to the file.
Return Value( NSInputStream initWithURL example )
An initialized NSInputStream object that reads data from the file at url. If the file specified by url doesn’t exist or is unreadable, returns nil.
( NSInputStream initWithURL example )
NSInputStream * stream = [[NSInputStream alloc] initWithURL:yamlURL];
( NSInputStream initWithURL example )
- (void)viewDidLoad
{

int actuallyRead=0;

NSString *path=[self dateFilePath];

NSURL *audiourl=[[NSURL alloc]initFileURLWithPath:path];

NSLog(@"%@",audiourl);

inStream=[[NSInputStream alloc] initWithURL: audiourl];
[inStream open];
actuallyRead=[inStream read:buffer maxLength:sizeof(buffer)];

NSLog(@"%d",actuallyRead);

[dataBuffer1 appendBytes:buffer length:actuallyRead];

NSLog(@"%d",actuallyRead);

[inStream release];

[super viewDidLoad];

}