Thursday, 16 February 2012
iPhone Code: how to cancel NSURLConnection
iPhone Code: how to cancel NSURLConnection: If the Connection still in progress means just considered as "connection" is a object of NSURLConnection then, ...
iPhone Code: write file to document directory
iPhone Code: write file to document directory: NSData *data=[[NSData alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"tamil.txt" ofType:nil] encoding:NSUTF8StringEnco...
Friday, 13 January 2012
write file to document directory
NSData *data=[[NSData alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"tamil.txt" ofType:nil] encoding:NSUTF8StringEncoding error:nil];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
NSString *writePath=[documentDirectory stringByAppendingPathComponent:@"tamil.txt"];
[data writeToFile: writePath atomically:YES];
Thursday, 12 January 2012
how to cancel NSURLConnection
If the Connection still in progress means
just considered as "connection" is a object of NSURLConnection
then,
if(connection)
{
[connection cancel];
}
just considered as "connection" is a object of NSURLConnection
then,
if(connection)
{
[connection cancel];
}
Tuesday, 10 January 2012
get file from resources folder
If you considered tamil.txt file exist in resources folder you want to get the content of file.
step 1:
First get the file path from resources folder
step 1:
First get the file path from resources folder
NSString *path=[[NSBundle mainBundle] pathForResource:@"tamil.txt" ofType:nil];
Step 2:
Then get content from path
NSString *Content=[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog(@"content===%@",Content);
Monday, 9 January 2012
load url with fragment
hi,
If your url has fragment means you have to extract that fragment alone.Then load basic url with fragment it will work.
If your url has fragment means you have to extract that fragment alone.Then load basic url with fragment it will work.
NSString* webStringURL = /*enter your file path here*/;
NSURL* url = [NSURL URLWithString:webStringURL];
NSString *fragment=[url frament];
NSURL *baseURL = [NSURL fileURLWithPath:tmp];
NSURL *fullURL = [NSURL URLWithString:[NSString stringWithFormat:@"#%@",fragment] relativeToURL:baseURL];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
Sunday, 8 January 2012
get path from known url
NSArray *pathstr1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [pathstr1 objectAtIndex:0];
NSString *pathString=[documentDirectory stringByAppendindString:@"/tamil.txt"];
NSUrl *url=[NSURL fileURLWithPath:pathString];
NSString *path=[url path];
NSLog(@"path==%@",path);
Friday, 6 January 2012
get the fragment of url.If fragment exist in given url
NSString *tmp=[[NSBundle mainBundle]pathForResource:@"tamil.txt" ofType:nil];
NSURL *baseURL = [NSURL fileURLWithPath:tmp];
NSString *fragment=[baseURL fragment];
NSLog(@"fragment===%@",fragment);
Thursday, 5 January 2012
get the file extension of given file
hi,
Considered as the tamil.txt file there in document folder. You want to get the file extension.
Step 1:
First you need to get the document folder path using below code
Considered as the tamil.txt file there in document folder. You want to get the file extension.
Step 1:
First you need to get the document folder path using below code
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
Step 2:
Then you need to get the exact file name path
NSString *path=[documentDirectory stringByAppendPathComponent:@"tamil.txt"];
Step 3:
Now you knew the exact path of file name.
then,
NSString *fileExtension=[path pathExtension];
NSLog(@"file extension ==%@", fileExtension);
Tuesday, 3 January 2012
files available in given path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
NSArray *array=[[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentDirectory error:nil];
NSLog(@"fileatpath====%@",array);
Monday, 2 January 2012
Sensors in iphone
1.proximity sensor
This is sensor which is used to avoid touch option while speaking.
2.Accellerometer
which is used to control device tilt functionality.
3.Compass Sensor
Which is used find a direction in map
4.light ambient sensor
Which is used to find light light density in around the phone.
This is sensor which is used to avoid touch option while speaking.
2.Accellerometer
which is used to control device tilt functionality.
3.Compass Sensor
Which is used find a direction in map
4.light ambient sensor
Which is used to find light light density in around the phone.
Get Document directory path
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];
Subscribe to:
Posts (Atom)