Getting twitter feed into NSArray - objective-c

How would I get the text of the last 10 tweets, for a specific twitter user, into an NSArray?

In more modern versions of iOS, you can access Twitter directly via the Social Framework. Twitter has some example code available which shows how to use it.
You could, if you need something for earlier versions of iOS, check out MGTwitterEngine. It'll take care of all the heavy lifting required. Specifically, the methods getUserTimelineFor sinceID startingAtPage count and getUserTimelineFor sinceID withMaximumID startingAtPage count will fetch what you're looking for. It is getting a little long in the tooth, however, so making use of the built-in iOS stuff is preferable.

You would have to parse the json with something similar to what is described here: http://blog.zachwaugh.com/post/309924609/how-to-use-json-in-cocoaobjective-c and here: http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/

Related

Shipment Tracking in iOS

iOS 4 automatically detects tracking numbers found in emails, notes, and messages and turns them into clickable links.
And it redirects to this URL,
http://trackingshipment.apple.com/?Company=UPS&Locale=&TrackingNumber=1Z1234567890123456
How can we use this API or library into our iOS apps so it will automatically detect or force detect shipping numbers?
Unfortunately, the publicly-released data detector types don't include common carrier tracking numbers. I wrote a small project showing how to detect UPS, USPS, and FedEx package numbers and got pretty good results:
You'll have to do the work of assembling the tracking URLs yourself, but this sample code may help you get started. Download here.
The class being used to do this is called NSDataDetector.
It is a subclass of NSRegularExpression where you can specify some built in patterns to look for.
The list of built in type values in the NSTextCheckingType enum can be seen here.
I don't see one specifically for tracking information, but the closest thing appears to be NSTextCheckingTypeTransitInformation. That is most likely the one you're going to be using.
Good luck!

IPhone Geocoding

There is absolutely no tutorials on geocoding on the iphone. Only reverse geocoding. I have an address, want to convert to coordinates, then display a streetview of that address. How can this be accomplished...
EDIT
The below answer pretty much echos what I found online, but I know this can be accomplished using Googles JSON geocoding. I am working on this now, will update post when I figure out how to pull out the coordinates.
"http://maps.google.com/maps/geo?q="+ address+"&key="+apiKey+"&sensor=false&output=json"
built in forward geocoding is new to iOS5. look at CLGeocoder, which includes methods like geocodeAddressString:completionHandler:. if you want to support pre-iOS5 then you'll have to use another service, e.g. google's. i haven't used it myself, but a quick search turned up: https://github.com/mjisrawi/iOS-Geocoding-Services which may be of use.

How to get and parse JSON using objective C?

Is it possible to get and parse JSON using objective C, then manipulate it within the cocoa framework for the iphone/pad? I'm specifically looking to do this for a couple of public APIs out there.
See here: how to do json parsing in iphone
Basically, you should look into the TouchJSON library (with CJSONDeserializer and CJSONSerializer).
Used Json-framework on some previous projects, worked really well.
EDIT: I read your post a bit too fast. I've used it on a Mac app before but not targeting the iphone/ipad. I think it should work but have no background to it. Maybe someone else can confirm?
It's not only possible, it's dirt simple if you use one of the many existing open source projects dedicated to this task. I recommend trying yajl-objc, which offers a streaming parser, but json-framework is a good one too. They're very similar.
I'd stay away from TouchJSON, since it gave me trouble a while back with special characters (line breaks) in strings.
However, I'll join the choir recommending json-framework. Since I switched to that from TouchJSON everything's been running smoothly.
Regarding how to integrate the API in your project, they're equally simple to include and use.
As a side note, I'm just now testing out JSONKit, since it's supposed to be much faster than both TouchJSON and json-framework. However, I can't vouch for its stability yet. The reviews of it are good, though.
If you're developing an application that is only iOS 5.0 or later, you can use NSJSONSerialization.

Objective c Twitter Api : which to use?

In the twitter's developer page mentioned three twitter engine for objective c:
MGTwitterEngine, Canary ,ShareKit.
Which is the best?
Is there another possibility?
Thanks in advance.
I've used MGTwitterEngine, and I've started to roll my own, since I'd like to use the streaming API and it doesn't have support for it. I like mine the best, but MGTwitterEngine is very easy to use. ShareKit I didn't much like when I gave it a go a few months back (adding Instapaper support to an app, ended up just writing my own Instapaper stuff too). I've never used Canary.
Objectively just talking about MGTwitterEngine and ShareKit, you'll be faster up and running with ShareKit, but you may not like using it long term.
All depends on what your needs.
MGTwitterEngine is mainly made for OS X / iPhone twitter applications
Canary focuses on multiple timelines, filtering and drag-n-drop functions
ShareKit isn't a Twitter specific kit but a social kit for multiple social platforms
You can try www.pinkelstar.com. Works out of the box for both iOS and Android.

Applescript Inside of a Cocoa Application

For the application I am writing, I need to access some other applications' items, for which Applescript seems the best way to go. I have been using the Appscript framework, which worked well, because it allowed me to thread it and not make my app lock up when an Applescript was taking a while. However, now I am attempting to make my application 64 bit compatible, and it seems like the Appscript framework does not support 64 bit. Is there a "good" way to use Applescript in Cocoa that will not lock up my application, but still give me the full control I need?
--firen
It seems like SBApplication should work, but I haven't used it before.
According to #cocoadevcentral:
SBApplication: use to make cross-application scripting calls with Objective-C instead of AppleScript. Ex: get current iTunes track.
Here is is the excerpt from the documentation:
The SBApplication class provides a mechanism enabling an Objective-C program to send Apple events to a scriptable application and receive Apple events in response. It thereby makes it possible for that program to control the application and exchange data with it. Scripting Bridge works by bridging data types between Apple event descriptors and Cocoa objects.
Although SBApplication includes methods that manually send and process Apple events, you should never have to call these methods directly. Instead, subclasses of SBApplication implement application-specific methods that handle the sending of Apple events automatically.
For example, if you wanted to get the current iTunes track, you can simply use the currentTrack method of the dynamically defined subclass for the iTunes application—which handles the details of sending the Apple event for you—rather than figuring out the more complicated, low-level alternative:
[iTunes propertyWithCode:'pTrk'];
If you do need to send Apple events manually, consider using the NSAppleEventDescriptor class.
Hope that helps!
As Blaenk mentioned Scripting Bridge may well be the way to go, although it can prove somewhat inefficient if you have to iterating through large arrays etc.
The simplest way to run an Applescript in Cocoa is using NSAppleScript.
Apple has some pretty good examples, which I found useful when I needed to do something similar. There are three articles you might want to take a look at. They all contain some sample code, which I always find very useful.
A Few Examples of using Scripting Bridge
Performance & Optimisation with Scripting Bridge
NSAppleScript Technote/Example
I created a gist with the full URLs as I can't post more than one link, what with being a newbie and all.
http://gist.github.com/130146
it seems like the Appscript framework does not support 64 bit.
Should work. Make sure you set the correct architectures and SDK (64-bit requires 10.5) in the Xcode project. File a bug report if you have a specific problem.