Objective C- Obtaining Page Screenshot/Image from URL - iphone

I'm writing an app that will take a csv file of URLs and should be able to display images of the URL pages that can be looked through. I'm wondering if anyone knows a way in Objective-C to get an image of a page from a URL? I know that it can be done with python and the qtWebKit, but I'm hoping that I don't have to write another script in python and that there is a way it can be done in Obj-C.
Thanks

At the bottom of this page you find the link to the source of Paparazzi!, a Mac app written in Objective-C and using WebKit that does pretty much what you're after.
Its current version's (v0.5) source is not available, but up to v0.3 it is and should be enough to get you started (or at least give you an idea).
Paparazzi! is a small utility for Mac OS X that makes screenshots of
webpages.
It’s written in Objective-C using the Cocoa API and the WebKit
framework.
It was inspired by webkit2png, a commandline tool written by Paul
Hammond in pyObjC.
http://derailer.org/paparazzi/

Related

Embed/Read Command Line Tool in a Cocoa App (Swift 3)

I'm new here, so please be kind - I am open for tips and corrections ;)
Actually I'm trying to write an OS for a Sportsmachine. It basically contains a Joystick (JoyWarrior A8) input via USB. After some time I am now able to read the axes of the Controller using XCode, a Swift Command Line Tool with OpenGL and GLFW. The axes position is put out into the console.
What I would like to do now is to use this output in a Cocoa App to write the UI.
My questions to you are:
Is there a way to integrate and read a Command Line Tool within a Cocoa Application?
Or is there a better way to directly integrate the input into my Cocoa App?
Thank you in advance! Please let me know if something isn't explained well enough or if you need some code snippet!
As a rule-of-thumb, if you ever find yourself wondering whether Apple has an off-the-shelf solution for a feature you're trying to implement, ask yourself if the feature would be of use to a significant number of other developers. If you think that it would, you should do some googling, because there's a good chance that you're right, and that Apple will already have a library/framework that does what you need. It's fair to say that interacting with a game controller is just such a feature, and, true to form Apple, provides API to save you from having to re-invent the wheel (or use third-party wheels) - here's the guide.

Porting Max/MSP .app to iOS

I've read a number of posts on Apple's forums, and a number of posts on the Cycling '74 forums (with my own questions scattered around both) and nobody seems to be able to help me.
I used Max/MSP to write a 'patch' that takes samples and generates music. I'm going to release it as an album similar to Brian Eno's Thursday Afternoon, but wanted to make it available to people so they can have the music last for more than the hour a CD can hold.
What I don't know how to do, and can't figure out is HOW. It looks just like a regular OS X app, and the only difference I see in the directory structure is that my Max/MSP made application has extra .framework folders as well as the objects I use (which I guess are similar to 'functions' in JScript). I've looked at the package contents of both OS X files and the unpacked .ipa files from the App Store. Being so similar I would imagine it'd be pretty easy.
Where do I start? Has anybody on this forum done this? Thanks for your time!
[edit] - I just wanted to let you know I've discovered RJDJ, an iOS app that allows users to create 'scenes' in Puredata (Pd) and load them on their RJDJ program. I'd rather not go this route.
[edit2] - ok. I agree that it's very different. Especially having 4 (i could cut it down to 3) additional frameworks that aren't part of the SDK. But Ive been thinking. I can add a JavaScript object inside of my program, or make a special new object (object in max is sort of like a class in JS, i think) using C. Is there anything in these languages that would be able to convert a simple 'touch' to a 'mouseclick' in my app?
My application is very very simple. Basically just samples, played at randomly generated time intervals with some a 'conductor' to bring in/out the groups the samples are drawn from (piano, fx, etc...). So the user just clicks the 'start' button and off it goes. So the .nib file I would need to create is very simple. In my head it seems like the .ipa package/ios .app both contain unix executables and so long as these are basically the same it should work, right?
Max6 has been released.
A new object/concept named gen~ is available.
As far as I discussed with C74 dev, I know gen~ WILL provide its source code output. This code produce by the gen~ object could be useable in any other framework. basically, it will be C++
So it would really open A LOT of possibilities ; Max becoming a real graphical framework producing output that can be used in programming world.
It would save time for some part of the code.
As far as I can see from poking around at the Cycling '74 site and forums, there's currently no Max engine available for iOS. libpd is probably your best bet, really. (I'd note that the Inception app uses this Pure Data engine with a custom interface and it works very well.)
Unfortunately OSX and iOS apps are completely different under the hood. Outwardly they look similar (eg. you've noted the .app extension) but the internals are completely different.

Best practices for parsing HTML from Wikipedia for iPhone viewing?

I am building an iPhone Wikipeida game app, that requires modifying the default Wiki HTML a little bit (mostly simplifying the page).
So far I am directly downloading the HTML output from en.wikipedia.org/wiki/Article_Foo to a python Google App Engine, and then modify its CSS and HTML structure, cache it, and finally output to iPhone. It works but I find this method quite tedious, there must be a better method?
Please note that I use App Engine not just for parsing the Wiki, but the game also requires it to keep the stores...etc, hence not a overkill. Also, I would prefer doing all the work with python on App Engine, to keep the iPhone client as thin and mobile as possible (XML on iPhone is a big no fun)
Thanks a lot.
=======
Nick mentions why not use the mobile Wiki which already optimizes for iPhone. However, the issue is that it goes down quite frequently (every couple weeks or so), also its HTML structure changes quite frequently too.
You can use the MediaWiki API to download the markup text and use some API tools for Python that could make the process/modify work easier.
Caching and outputting to iPhone is fine. I believe there is not much to simplify here.
Why not just fetch the mobile version of the page from http://en.m.wikipedia.org/? This is already formatted for mobile devices.
You can set up your own copy of the server used by m.wikimedia.org:
http://github.com/hcatlin/wikimedia-mobile
It's written in Ruby, but this shouldn't be an issue if your app just uses the HTML output.

Web search in an iPhone app

I've got experience in C/C++ and am trying to now learn Objective-C for iPhone development. I have very little web design experience.
I'm trying to create an app for a friend's site that accesses a search feature from a website and then display the results in a UITableView. For example, (this isn't the site I'll be using, but...) using the stackoverflow search function and then being able to format the results (https://stackoverflow.com/search?q=iphone+web+search) in cells. I'd like to leave out the rest of the content on the page.
I've only been able to find info about reading xml or rss search results. Otherwise, I could use UIWebView, but that displays the entire site. Are there other classes that I should look into for doing this? Any help would be very, very much appreciated!
The iPhone SDK doesn't include Cocoa libraries for parsing HTML. Just NSXMLParser, which isn't a good tool for what you want to do. (It will choke on valid HTML that isn't valid XML.)
This page is probably a good first place to look. The author says, "For scraping/reading a webpage, XPath is the best choice. It is faster and less memory intensive then NSXMLParser, and very concise. My experience with it has been positive."

Is there a good iphone sdk documentation site that provides good examples / common usage?

The problem? I look up stuff in the xcode documentation and find very useful lists of objects, methods, etc... But then I still have to go somewhere else to find useful example code of how to use that object. For example, I looked up NSNumber yesterday and found all of the neat stuff it can do, but I still had no clue how to use it. That's just an example. I'm sure I could read the objective c pdf front to back and learn something there (which I plan on doing) but what about later? When I'm looking up some UIKit object? Do I have to go find a tutorial each time (or lately, I just ask StackOverflow and you guys take care of me).
Is there a part of the apple website / xcode documentation that shows the example code I'm looking for?
Is there a wiki site out there or something that has what I'm looking for? (I just tried a simple google search "iphone sdk wiki". this site could be good. iphone sdk wiki . I'll check it out. Anyone else have one they like? )
This is also sort of a mild complaint to Apple. Why not a section on each code definition page that shows usage?
I've found the sample code section on Apple's iPhone Developer Connection be extremely useful not only for samples of complete applications but also a best practices source. Going through the code of The Elements, for example, will expose you to how to use particular classes as well as how to structure your code. It is a wonderful example of how to create a non-trivial iPhone app.
Look in developer.apple.com/iphone they have pretty good documentation (you can use the search bar there) on all the classes and have a lot of good sample code..
I really would emphasize the "Related sample code" section on many, if not most, of the documented classes.
But, IMHO, there isn't any easy way of acquiring the knowledge to develop in Cocoa/Cocoa Touch. The API's are so numerous that it simply takes a lot of time and experience. You just have to work on it, look at a lot of books and study the sample source code where available.
I've tried to take a purposeful approach by carving out some time every week to learning a new API/class irrespective of whether my current project needs it or not.
Alternatively, search Joe Hewitt. He's the developer for iPhone facebook. He has a project you can download that demonstrates all the features of facebook. It's an awesome open source project!
When you look something up in Xcode Developer Documentation, you sometimes get a Related Sample Code: text that tells you what Sample the method or property is used in. Too bad you can't click on it to see the code, but if you do click it takes you to the page to download the sample. – mahboudz 0 secs ago
Apple Developer site has all kinds of code examples. Try searching google for a UICatalog project, it will show you all the basic UI stuff you can do, like adding buttons and progressbars through using only code.