开发者

ShareKit - How to access the Twitter username

开发者 https://www.devze.com 2023-01-23 09:37 出处:网络
Currently I have set up my application to take advantage of the XAuth implementation of Twitter services via ShareKit. Those that are aware of ShareKit and have implemented it into your own applicatio

Currently I have set up my application to take advantage of the XAuth implementation of Twitter services via ShareKit. Those that are aware of ShareKit and have implemented it into your own application either for testing purposes or for adding the huge array of services it implements to your application, you'd be well are that we have a SHKTwitter.h and .m and an SHKTwitterForm.h and .m which can be found under the Sharers folder in the source code.

It is here that I have started to implement my own TwitLonger support for ShareKit. However, I've run into a few problems. For those that haven't used the TwitLonger API, they only need the Twitter users username to actually send the Tweet. However, I am struggling to pull the entered Twitter username from the SHKTwitterForm.

Currently, after talking to Nate (the developer of ShareKit) I put together this to pull the username key from the NSMutableDictionary, save to an NSString and then save that into an NSUserDefault object. This is then called when my TwitLonger API implementation kicks in by creating a new NSString built from the NSUserDefault object.

In my SHKTwitter.m I created a subclass of -(void)authorizationFormSave:(SHKFormController *)form as directed by Nate. As you can see below, this is what I have.

- (void)authorizationFormSave:(SHKFormController *)form 
{

 NSMutableDictionary *dict = [form formValues];

 NSArray *keys = [dict allKeys];
 NSString *usernameString = [[keys valueForKey:@"username"] componentsJoinedByString:@""];


 [[NSUserDefaults standardUserDefaults] setObject:usernameString forKey:@"twitter_name_preference"];
 [[NSUserDefaults standardUserDefaults] synchronize];
}

However, whenever I call this NS开发者_开发百科UserDefault object into a new NSString in my SHKTwitterForm.m, it returns nil.

Anyone have any idea as to how I could achieve this even more simply or am I doing it correctly? I feel as though the way that I'm grabbing the object in the NSMutableDictionary wrong. Any help would be appreciated!


You need to ask the dictionary object for valueForKey.

For example:

NSString *usernameString = [dict valueForKey:@"username"];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号