How to access Twitter Account Followers into iphone using iOS5? [duplicate] - iphone

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Get twitter Follower in IOS 5
How to access Twitter Account Followers into iphone using iOS5?
I am new to iOS5 , can u please suggest with some code or links.
Thanks in Advance
Bhaskar

In IOS5 twitter is intregated.... then No Use Extra frameWork...
try this code
- (void)OnTwitter {
Class TWTweetComposeViewControllerClass = NSClassFromString(#"TWTweetComposeViewController");
if (TWTweetComposeViewControllerClass != nil) {
if([TWTweetComposeViewControllerClass respondsToSelector:#selector(canSendTweet)]) {
UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];
[twitterViewController performSelector:#selector(setInitialText:)
withObject:twitterText];
[twitterViewController performSelector:#selector(addURL:)
withObject:[NSURL URLWithString:url]];
[twitterViewController performSelector:#selector(addImage:)
withObject:urImage];
[self presentModalViewController:twitterViewController animated:YES];
[twitterViewController release];
}
else {
// Use ShareKit for previous versions of iOS
}
}
import the farmeWork in your Class
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>

You can use this link to find how to access twitter accounts
Then you can easily use the API to find the followers

Related

link to a book in iBook store from an iphone app

After looking around I could not get a straight answer to the following case: can I link to a book in the iBook store from my iphone app without integrating the in-app purchases API?
As far as I know, iBooks does charge you for placing the book, so my logic says that it should be possible since otherwise you would be charged twice.
Many thanks.
If your app is targeting iOS 6.0 you can use the new SKStoreProductViewController to allow users to purchase iTunes, App Store, and iBooks content directly from your app without having to leave it.
Here is how to present it from a UIViewController. You must add the StoreKit.framework to your application.
ViewController.h
#import <StoreKit/StoreKit.h>
#interface UIViewController : UIViewController <SKStoreProductViewControllerDelegate>
#end
ViewController.m
-(void)showProductPageForProductID:(NSInteger)productID {
SKStoreProductViewController *sv = [[SKStoreProductViewController alloc] init];
sv.delegate = self;
NSDictionary *product = #{ SKStoreProductParameterITunesItemIdentifier: #(productID)};
[sv loadProductWithParameters:product completionBlock:^(BOOL result, NSError *error) {
if(result)
[self presentModalViewController:sv animated:YES];
else {
//product not found, handle appropriately
}
}];
}
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
[viewController dismissModalViewControllerAnimated:YES];
}
If your targeting devices below iOS 6.0 you can just use this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://itunes.apple.com/us/book/the-casual-vacancy/id518781282?mt=11"]];
Just replace that URL string with your link, and it will leave your app and enter the iBooks app displaying that product.
If you want to target both iOS 6.0 and lower, you can just check if they have the new SKStoreProductViewController by using the following conditional
if([SKStoreProductViewController class]) {
//show the SKStoreProductViewController
}
else {
//use UIApplication's openURL:
}
In order to get the Apple product ID for a product, you can just check the URL to the product for example:
http://itunes.apple.com/us/book/the-casual-vacancy/id518781282?mt=11
The product ID is 518781282. It comes after the id portion in the URL. Don't include the ? or anything after it.

What will happen to users running a lower version of IOS if new code is called?

I am fairly new to iOS Development and I've always wondered if a user running my application on iOS 4 were to try and run this code:
//POST TWEET//
- (void)showTweetSheet
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result) {
switch(result) {
case TWTweetComposeViewControllerResultCancelled:
break;
case TWTweetComposeViewControllerResultDone:
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES completion:^{
NSLog(#"Tweet Sheet has been dismissed.");
}];
});
};
[tweetSheet setInitialText:#"Check out this cool picture I found on #Pickr_"];
// Add an URL to the Tweet. You can add multiple URLs.
if (![tweetSheet addURL:[NSURL URLWithString:ImageHost]]){
NSLog(#"Unable to add the URL!");
}
[self presentViewController:tweetSheet animated:YES completion:^{
NSLog(#"Tweet sheet has been presented.");
}];
}
What would happen? Would the application just terminate with an error or will the code just not run? And how do I properly implement features that are OS specific? Would I just use something like this:
NSString *DeviceVersion = [[UIDevice currentDevice] systemVersion];
int DeviceVersionInt = [DeviceVersion intValue];
if (DeviceVersionInt > 5)
{
//do something.
}
else
{
//don't do a thing.
}
It will crash on iOS 4 if you write iOS5 features without checking if they are available or not. Try to implement Twitter like this
Class twClass = NSClassFromString(#"TWTweetComposeViewController");
if (!twClass) // Framework not available, older iOS
{
//use iOS4 SDK to implement Twitter framework
}
else {
//use Apple provided default Twitter framework
}
Make sure you have added Twitter Framework with weak link.
Id imagine that it would work the same as with any other api. If you link against a function which is not in a previous version, the program will crash on an attempt to call the function. Therefore, version switches are used, as you demonstrated, to avoid crashes.
The app would crash. If you want to implement features based on iOS, you can use a variety of methods. See this question.

Access Photo Library via Objective-C/Xcode in iOS

I'm writing an iPhone application. I'm wondering if I can get a list of files/filenames of the photos stored in the iPhone library (or those in the simulator).
Essentially, I'm asking if I can get the filenames of the photos stored on the iPhone or simulator.
I appreciate any help, thanks!
EDIT:
image = [UIImage imageNamed:#"/Users/Library/Application Support/iPhone Simulator/5.0/Media/DCIM/100APPLE/IMG_0002.jpg"];
imageView.image = image;
doesn't work, unfortunately.
You simply have to use the UIImagePickerController.
It gives something like that:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
// Don't forget to add UIImagePickerControllerDelegate in your .h
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
This is something of a duplicate of a SO question asked already here - Get list of all photo albums and thumbnails for each album
From that answer:
Take a look at AssetsLibrary framework.
Note that if you have access to the iOS 6 Beta, you'll want to note the changes taking place for accessing those assets. Can say no more per NDA.
Using this methods, you can easily implement that.
https://www.dropbox.com/sh/trmg44a93hwq35x/AACAVGY6VKEDR0tDUOqoxd-Ba?dl=0

Problems building for both iOS4.3 and iOS5.0

I'm running up against problems trying to incorporate some iOS5-specific libraries into an app targeted at both iOS5 and iOS4.3. I've gone through the following steps:
weakly-linked the Twitter framework by setting it as optional in 'Link Binary with Libraries"
added it as a framework for the iOS5.0 SDK in Other Linker Flags with `-framework Twitter.framework'
conditionally linked the framework in the class header:
#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>
#endif
then in the method itself, I'm then checking whether the user's set up for Twitter:
if ([TWTweetComposeViewController class]) {
self.canTweet = [TWTweetComposeViewController canSendTweet];
}
This works beautifully on both the 5.0 and 4.3 simulators. However, I've got problems getting it to run on, or archive for, actual devices.
When I've got either a 3GS running 5.0, or a 4 running 5.0 attached, both show up twice in the Scheme dropdown. Selecting the top one, and attempting build or run the project fails with an Use of unidentified identifier 'TWTweetComposeViewController' error.
Using the second device entry, the build fails with a ld: framework not found Twitter.framework error.
I'm sure there's something I'm missing here, but I'm stumped. Can anyone advise?
If you are using a week linking then you have to check first availability of API using
NSClassFromString, respondsToSelector, instancesRespondToSelector etc.
So, change your if condition. First try to get your class object using above specified runtime function.
here is a link explaining in detail how to do such.
link
The code for presenting twitter controller
Before this you have to add the frameworks as optional and make the import in h file if iOS is min iOS 5
Class TWTweetComposeViewControllerClass = NSClassFromString(#"TWTweetComposeViewController");
if (TWTweetComposeViewControllerClass != nil) {
if([TWTweetComposeViewControllerClass respondsToSelector:#selector(canSendTweet)]) {
UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];
[twitterViewController performSelector:#selector(setInitialText:)
withObject:NSLocalizedString(#"TwitterMessage", #"")];
[twitterViewController performSelector:#selector(addURL:)
withObject:url];
[twitterViewController performSelector:#selector(addImage:)
withObject:[UIImage imageNamed:#"yourImage.png"]];
[self.navigationController presentModalViewController:twitterViewController animated:YES];
[twitterViewController release];
}
}
Further digging into the error thrown back by the compiler suggested that it was ignoring the weak link flag. Although I've no idea how or why, it was fixed by a reinstallation of XCode.
if you link to 4.2 or later and deploy to 3.1 or later, you can use the new weak linking features to make this check simple.
you have to add Twitter frameworks as optional and then
Class TWTweetComposeViewControllerClass = NSClassFromString(#"TWTweetComposeViewController");
if (TWTweetComposeViewControllerClass != nil)
{
if([TWTweetComposeViewControllerClass respondsToSelector:#selector(canSendTweet)])
{
UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];
[twitterViewController performSelector:#selector(setInitialText:)
withObject:NSLocalizedString(#"TwitterMessage", #"")];
[twitterViewController performSelector:#selector(addURL:)
withObject:url];
[twitterViewController performSelector:#selector(addImage:)
withObject:[UIImage imageNamed:#"yourImage.png"]];
[self.navigationController presentModalViewController:twitterViewController animated:YES];
[twitterViewController release];
}
}

how to integrate my iphone app with twitter api?

I need to tweet and also retrieve tweets.is any api available for this, any sample application or code .
.thank you in advance
This is now built in to iOS5. Take a look at the Twitter Framework Reference
if you're planning to support iOS version before 5.0, have a look on the MGTwitterEngine, http://mattgemmell.com/2008/02/22/mgtwitterengine-twitter-from-cocoa/
see this link may be it help to u
https://github.com/bengottlieb/Twitter-OAuth-iPhone/
here some code
- (void)viewDidAppear: (BOOL)animated {
// Twitter Initialization / Login Code Goes Here
if(!_engine){
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
_engine.consumerKey = kOAuthConsumerKey;
_engine.consumerSecret = kOAuthConsumerSecret;
}
}
if([_engine isAuthorized])
{
[_engine sendUpdate:#"your posting data"];
}
import authtwitterengine
I agree with Benjie, you should try and use the Twitter API that's built into iOS 5. Here's how: http://www.peterfriese.de/the-accounts-and-twitter-framework-on-ios-5/