download and open zip folder path in iphone - iphone

i download a zip file from web server and store on a specific location.
is it possible after downloading user can see that downloaded file ? i mean how user know where file is stored so instead of searching by user i want to open that folder for user...and if this possible then how?
thank you in advance

Are you downloading the zip file within the app and storing it somewhere?

#pooja i had worked on the same situation....in my case i was downloading the zip file from web server and i was saving that file to the documentsDirectory itself.Now as you are saying that how will user came to know that the file is downloaded or not. Then in this case i would suggest you or what i had done was.....
//Your request
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setDelegate:self];
[request setDownloadDestinationPath://Your path here];
[request setDidFailSelector:#selector(zipFileDownloadFailed:)];
[request setDidFinishSelector:#selector(zipFileDownloaded:)];
- (void)zipFileDownloaded:(ASIHTTPRequest *)request{
UIAlertView *Downloaded = [[UIAlertView alloc] initWithTitle: #"Successfully Downloaded" message: #"" delegate:nil cancelButtonTitle: #"Ok" otherButtonTitles: nil];
[Downloaded show];
[Downloaded release];
Downloaded = nil;
}
- (void)zipFileDownloadFailed:(ASIHTTPRequest *)request{
UIAlertView *DownloadFailed = [[UIAlertView alloc] initWithTitle: #"Download Failed" message: #"" delegate:nil cancelButtonTitle: #"Ok" otherButtonTitles: nil];
[DownloadFailed show];
[DownloadFailed release];
DownloadFailed = nil;
}
Now this alert will conform the user that the file is successfully downloaded or not....Now use this file wherever you want in your app...user is now conformed that the file is downloaded or not ......no need to show that to him at that place where you are downloading the file that will be something which will be so complicated.
Edited my code as per your last comment : Yes you have to unzip that file whose zip file you had downloaded within your application only..How will user unzip that file .....you have to unzip that file programatically and you have to show the contents of that file in your application.....Look there is a predefined API to zip and unzip files so try doing some searches and unzip your file in your application....
Also have a look on iPhone Unzip code as asked earliar and also download the ziparchive from here......i had taken help from all of them.
Hope you got my point and this answer will be useful to you.
Good Luck!

Related

.dylib mobile substrate tweaks not working

I was learning about making mobile substrate tweak when i came across a tutorial with a source codes in it. To further understand it, i decided to test it out
The codes:
%hook SBApplicationIcon
-(void)launch
{
NSString *appName = [self displayName];
NSString *message = [NSString stringWithFormat:#"The app %# has been launched, lol", appName, nil];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:appName message:message delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
%orig;
}
%end
I used theos on my IOS phone and made a tweak and paste this code into the "tweak.xm"
I went to "makefile" and added
test_FRAMEWORKS = UIKit
if u ever wonder what is in my test.plist, here is it
com.apple.springboard
Next i went to mobile terminal and did this
su
alpine
cd test
make
Then u copied the .dylib and the "test.plist" file that theos made and pasted it in /Library/MobileSubstrate/DynamicLibraries
After that i respring my device and tried launching an app, but nothing happened. Everything launched normally. Please help me here
After googling for a long time, i finally made it to work
I went to mobile terminal... and login. After that i did this
installsdk3
Then i went to my Makefile and changed it to this
SDKVERSION = 3
include theos/makefiles/common.mk
TWEAK_NAME = test
test_FILES = Tweak.xm
test_FRAMEWORKS = UIKit Foundation
include $(THEOS_MAKE_PATH)/tweak.mk
And i remade the tweak again and it worked!

sendAsynchronousRequest got Timeout Error on iPhone

My App allows user to take photo and upload it to a PHP server. I use sendAsynchronousRequest calls to send data (form with photo files) to the server. All those calls are working just fine on my iPad 2 when debugging. But when I debugged it on iPhone 4S, some of them get errors with error code, -1001, which represents Timeout error. I tried for thousand times in the past two days to find its root cause, but I still can't find one.
Has anybody encounters similar situation? or knows why?
The only clue I got is that if there are more than one file in the request data (original photo file and resized thumb file), it will receive time out error. Is it about request (photo file) size? or file number?
I handled the ASIHTTP request failed using this simple method.
- (void)requestFailed:(ASIHTTPRequest *)request {
NSError *error = [request error];
if([error code] == ASIRequestTimedOutErrorType ) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Error"
message:#"Connection Timed out"
delegate:self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
return;
} else if ( [error code] == ASIConnectionFailureErrorType) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Error"
message:#"Connection Failiure"
delegate:self
cancelButtonTitle:#"Ok"
otherButtonTitles:nil];
[alert show];
return;
}
}
You can also set your connection time out in your request
like
[request_ setTimeOutSeconds:50.0];
This will wait for 50 seconds and show connection timed out error.
I solved the problem. It caused by upload big size file. The original photo token by iPhone 4s is about 5M big. If the network is not fast enough, the connection will be time out.

How to view files in iPhone app?

I am building an iPhone app that can save email attachments. I would like to be able to view the files from inside the application as well. I need to be able to view as many kinds of files as possible: .txt, .pdf, .png, .jpeg., .doc, .xls, etc.
The files will reside inside of my application's documents folder. What is the best solution for this? My first thought is to convert my file-paths to URLs and load them in a UIWebView, but I'm not sure if this is the best way, or if it will handle all those file types. Any thoughts?
The way Apple's own Mail app does this is with the QuickLook framework. I'd suggest you do the same. QLPreviewController does all the heavy lifting for you. You can also use UIDocumentInteractionController; this is still using QuickLook behind the scenes to generate the preview.
The UIWebView is the best way to show this kind of file.
Alternatively you can try to read the document in an other app with this code:
UIDocumentInteractionController *interactionController = [[UIDocumentInteractionController interactionControllerWithURL:document.documentURL] retain];
interactionController.delegate = self;
BOOL canOpenDocument = [interactionController presentOpenInMenuFromRect:CGRectMake(365, 200, 300, 400) inView:self.view animated:YES];
if(!canOpenDocument) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"" message:#"Your phone can't read this kind of file, please install an app from appstore for that" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}

picking and uploading the video for iphone 3g ios 4

I want to upload a video from iPhone to a server somewhere.
I have found this useful question here for uploading a video on the server from iPhone.
The only problem here is picking the video. The code is using uiimagepickercontroller to pick up the video and I have a 3g phone which has not video in its photos app. I can't even put a video in it . I have a video only in iTunesU . Currently I am using following snippet for uiimagepickercontroller .
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
else {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Error accessing photo library"
message:#"Device does not support a photo library"
delegate:nil
cancelButtonTitle:#"Drat!"
otherButtonTitles:nil];
[alert show];
[alert release];
}
So I have to ask that is it necessary to pick a video from uiimagepickercontroller and if so how can I do so with my iPhone 3G .
Please tell me if the question is not readable.
Thanks .
There is no video support for 3G that I am aware of.
In order to make it work (you could simulate it) you need to pass a mediaType of 'kutTypeMedia', which errors as not available on your device.
'If' you want to test, you can copy a video from the bundle, into your Camera Roll and test on the simulator.
Something like this to copy the video from the bundle to your camera roll:
Copy a video file from your bundle and save it to the album as below!
"Bundle Path :
(Where APPLCIATIONGUID and user are dynamic and depend on the logged on user and the applicationGUID)
'/Users/user/Library/Application Support/iPhone Simulator/4.0/Applications/APPLICATIONGUID/Documents'
Where APPLICATIONGUID is the GUID associated with your particular project. You can confirm that you are in the right folder by looking for the appropraite .app file.
Note:// I don't believe that this will work with a MOV but have tried nothing but a .m4v.
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:#"Documents/VID_0001.m4v"]];
NSString *videoFilepath = [[NSBundle mainBundle] pathForResource:#"VID" ofType:#"m4v"];
NSLog(#"Filepath is: %#", videoFilepath);
//test video can save to the photos album first - code missing
UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, #selector(video:didFinishSavingWithError:contextInfo:), nil);*
Once this has been done - videos are available in your photo album for selecting should you be setting up your UIImagePickerController with the correct media type.
This is the only option I see that you have to work with Video without a 3GS.

Trying to add a Vibrate and Sound to my Alert View

One thing I've learned at engineering school is to always to intense validation of input. I think it's great that with the iPhone SDK you can create a sound and a vibrate option. I would like to put both of these into my Alert View, which shows when the user doesn't fill in a field correctly.
However, I'm getting a ton of errors. Is it not possible to put the vibrate and sound options within an alert view? Here is the code I am using below,
//create vibrate
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
//play sound
SystemSoundID pmph;
id sndpath = [[NSBundle mainBundle]
pathForResource:#"mySound"
ofType:#"wav"
inDirectory:#"/"];
CFURLRef baseURL = (CFURLRef) [[NSURL alloc] initFileURLWithPath:sndpath];
AudioServicesCreateSystemSoundID (baseURL, &pmph);
AudioServicesPlaySystemSound(pmph);
[baseURL release];
//show alert view
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Age Error"
message:#"Your age must be at least 40 years old and less than 100 years old"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
I have all of the above code in the
- (void)textFieldDidEndEditing:(UITextField *)textField
method.
Here is the errors I get when I try to run it
http://screencast.com/t/Nzc5NDdhMmI
Any help would be greatly appreciated. Not sure what I'm doing wrong since I'm pasting this code directly from another source online.
I've never used the Sound Services, but it looks like you need to import the AudioToolbox framework.
#import <AudioToolbox/AudioToolbox.h>