download web page source code on iphone [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I need to download a particular webpage on my iphone.
It redirects me if i use a desktop.
Any tools out there that could help me to do this?
I have tried sitesucker but it didnt work.
Thanks!

If it redirects you when you use a desktop to access it, you can right click the link and download page as source. But since you want to do it on the iPhone, you can do the following:
// Download webpage
NSURL *url = [NSURL URLWithString:#"https://yourURL.here"];
NSData *urlData = [NSData dataWithContentsOfURL:url];
[urlData writeToFile:filePath atomically:YES];
And you can access the data through your simulator folder or you directly get the NSString.
NSURL *url = [NSURL URLWithString:#"https://yourURL.here"];
NSString *source = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL]

Related

Accessing Document directory in iOS storing and retrieving data [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm building a data which can store images into iOS document directory. I'm able to store the data in the document directory but how can I access it.And what is purpose of directory in iOS apps when there is persistent data store technologies like core data.Whether I can use directory to get persistent storage or I should go for core data.
I think, document directory is better solution in your case. Core data is useful for maintaining records corresponding to multiple fields.
Just use NSFileManager, something like this:
[[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];
It will give you an array with all the file paths for all files in the given path.
This is how you load the images from the array of URLs.
NSArray *paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];
for (NSURL *url in paths)
{
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
}
Have you tried using UIDocumentPickerViewController?
This is Apple documentation: https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller
Here is a tutorial:
https://medium.com/flawless-app-stories/a-swifty-way-to-pick-documents-59cad1988a8a

Html file in ios [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Hey guys im new to ios programming and new to objective C. My question is is it poosible to display a html file that is stored in the supporting files folder to display in a webview upon click of a button.
If you want to load a local HTML file within the app, then use the below code
self.wView.dataDetectorTypes = UIDataDetectorTypeLink;
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:INDEX_PAGE ofType:#"html" inDirectory:DIRECTOY_PATH]]; //Directory Path Example: ipad/main/pages
[self.wView loadRequest:[NSURLRequest requestWithURL:url]];
Put this code in your button handler method

How to access phone memory from application - iOS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have an music application that plays songs from urls using AVPlayer. According to new requirement user should be able to listen their local songs (contines in phone memory) also through this music app. I want to know few things about this.
1) How to access local memory within my application.
2) Can I use already exists AVPlayer to play local songs too.
Any tutorial or examples uch appreciated.
Thanks
1) It depends on what you mean by 'local memory'. You app's local folder, or the device's iPodLibrary?
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory()
stringByAppendingPathComponent:#"Documents"];
NSLog(#"Content of local documents directory: %#",
[fileManager contentsOfDirectoryAtPath:documentsDirectory error:nil]);
This will print out all the files that's currently in your app's document-folder. You can store files here too. This is only for your app, not shared by any other app on your device. I do not think you're able to find the .m4a-audio files from your iPod from your application, I'm guessing Apple has hidden them so developers can't mess with them, or start pirating etc.
2) As it turns out, it looks like you can! Take a look at this answer.

How to get my Facebook Profile Picture as button image [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
How can i get facebook profile picture and set it as button image. I have a button that will show facebook picture as its image. Help me out
Here is the simple stuff:
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:#"https://graph.facebook.com/1457691266/picture?type=square"]];
// Exchange 1457691266 with the ID of the user
yourProfilePicBtn.imageView.image = [UIImage imageWithData:imageData];

How to use MPMediaPickerController with Local Files in Documents Directory? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I want to be able to use the MPMediaPickerController on local files that were downloaded in the Documents directory.
However, there is no option to set the source of the files that the controller looks in, which defaults of course to the iPod music library.
Are there any methods to load local files, or any alternate libraries available to provide the media picking functionality? Or will I have to reinvent the wheel here :(
You might want to take a look at AVAudioPlayer instead, seeing as MPMediaPickerController is a class designed to play music stored only in the iTunes media folder. It's also very easy to play media with from the doc directory:
NSString *soundFilePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]stringByAppendingPathComponent:#"mySong.m4a"];
NSURL *fileURL = [NSURL URLWithString:soundFilePath];
NSError *error;
AVAudioPlayer* audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&error];
if(!error){
audioPlayer.delegate = self;
[audioPlayer play];
}else{
NSLog(#"Error loading clip: %#", [error localizedDescription]);
}

Resources