Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 无法在ios应用程序中导入yahoo联系人获取错误_Objective C_Ios_Yahoo Api - Fatal编程技术网

Objective c 无法在ios应用程序中导入yahoo联系人获取错误

Objective c 无法在ios应用程序中导入yahoo联系人获取错误,objective-c,ios,yahoo-api,Objective C,Ios,Yahoo Api,我已经从下载了这个项目。 我改变了消费观念, 消费者信用 和ApplicationId,但当我运行应用程序时,它崩溃了。它给出了一个错误的严重过剩。 有人知道这个吗?? 请告知 谢谢 基本上它只是从雅虎的开发者页面下载的项目。 这是我的完整代码 SocialSampleAppDelegate.h文件 SocialSampleViewController.m 信息普利斯特 你试过调试你的应用程序吗?什么是控制台日志输出?伙计,我做了,但它没有给我任何东西。在这一行之后,它将崩溃launchDefa

我已经从下载了这个项目。 我改变了消费观念, 消费者信用 和ApplicationId,但当我运行应用程序时,它崩溃了。它给出了一个错误的严重过剩。 有人知道这个吗?? 请告知 谢谢 基本上它只是从雅虎的开发者页面下载的项目。 这是我的完整代码 SocialSampleAppDelegate.h文件

SocialSampleViewController.m

信息普利斯特

你试过调试你的应用程序吗?什么是控制台日志输出?伙计,我做了,但它没有给我任何东西。在这一行之后,它将崩溃launchDefault=YES@RahulVyas我已经编辑了这篇文章,这样你就可以看到我的代码了。我只对从我的应用程序下载的代码做了4个主要的更改,我传递了我的应用程序的消费者密钥、密码、应用程序ID和URL方案。代码看起来不错。但要调试,我需要一个示例应用程序。通过邮件向我发送演示代码。@RahulVyas在plist文件中发现解决方案的值不正确。我设置了正确的值,现在可以工作了。你试过调试你的应用程序吗?什么是控制台日志输出?伙计,我做了,但它没有给我任何东西。在这一行之后,它将崩溃launchDefault=YES@RahulVyas我已经编辑了这篇文章,这样你就可以看到我的代码了。我只对从我的应用程序下载的代码做了4个主要的更改,我传递了我的应用程序的消费者密钥、密码、应用程序ID和URL方案。代码看起来不错。但要调试,我需要一个示例应用程序。通过邮件向我发送演示代码。@RahulVyas在plist文件中发现解决方案的值不正确。我设置了正确的值,现在它可以工作了。
#import <UIKit/UIKit.h>
#import "YOSSession.h"

@class SocialSampleViewController;

@interface SocialSampleAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    SocialSampleViewController *viewController;

    YOSSession                  *session;
    NSMutableDictionary         *oauthResponse;
    BOOL                        launchDefault;
}

    @property BOOL launchDefault;
    @property (nonatomic, readwrite, retain) YOSSession *session;
    @property (nonatomic, readwrite, retain) NSMutableDictionary *oauthResponse;

    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet SocialSampleViewController *viewController;

    - (void)getUserProfile;
    - (void)createYahooSession;
    - (void)handlePostLaunch;

    @end
#import "SocialSampleAppDelegate.h"
#import "SocialSampleViewController.h"

#import "YOSUser.h"
#import "YOSUserRequest.h"
#import "NSString+SBJSON.h"

@implementation SocialSampleAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize session;
@synthesize launchDefault;
@synthesize oauthResponse;


    - (void)applicationDidFinishLaunching:(UIApplication *)application {    

        // Override point for customization after app launch    
        [window addSubview:viewController.view];
        [window makeKeyAndVisible];

        launchDefault = YES;
        [self performSelector:@selector(handlePostLaunch) withObject:nil afterDelay:0.0];
    }

    - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
    {
        launchDefault = NO;

        if (!url) { 
            return NO; 
        }

        NSArray *pairs = [[url query] componentsSeparatedByString:@"&"];
        NSMutableDictionary *response = [NSMutableDictionary dictionary];

        for (NSString *item in pairs) {
            NSArray *fields = [item componentsSeparatedByString:@"="];
            NSString *name = [fields objectAtIndex:0];
            NSString *value = [[fields objectAtIndex:1]   stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

            [response setObject:value forKey:name];
        }

        self.oauthResponse = response;

        [self createYahooSession];

        return YES;
    }

    - (void)handlePostLaunch
    {
        if(self.launchDefault) {
            [self createYahooSession];
        }
    }

    - (void)createYahooSession
    {
            // create session with consumer key, secret and application id
         // set up a new app here: https://developer.yahoo.com/dashboard/createKey.html
    // because the default values here won't work
        self.session = [YOSSession sessionWithConsumerKey:@"MYConsumer KEy" 
                                    andConsumerSecret:@"MY Secret" 
                                     andApplicationId:@"My APPID"];

        if(self.oauthResponse) {
            NSString *verifier = [self.oauthResponse valueForKey:@"oauth_verifier"];
            [self.session setVerifier:verifier];
        }

        BOOL hasSession = [self.session resumeSession];

        if(!hasSession) {
            [self.session sendUserToAuthorizationWithCallbackUrl:nil];
        } else {
            [self getUserProfile];
        }
    }

    - (void)getUserProfile
    {
    // initialize the profile request with our user.
        YOSUserRequest *userRequest = [YOSUserRequest requestWithSession:self.session];

    // get the users profile
        [userRequest fetchProfileWithDelegate:self];
    }

    - (void)requestDidFinishLoading:(YOSResponseData *)data
    {
        NSDictionary *userProfile = [[data.responseText JSONValue] objectForKey:@"profile"];
        // NSLog(@"%@",[userProfile description]);
        if(userProfile) {
            [viewController setUserProfile:userProfile];
        }
    }


    - (void)dealloc {
        [viewController release];
        [window release];
        [super dealloc];
    }


    @end  
 - (void)viewDidLoad {
        [super viewDidLoad];

        [nicknameLabel setText:@"loading..."];
    }

    - (void)setUserProfile:(NSDictionary *)data
    {
        NSString *welcomeText = [NSString stringWithFormat:@"Hey %@ %@!", 
                             [[data objectForKey:@"profile"] objectForKey:@"givenName"],
                             [[data objectForKey:@"profile"] objectForKey:@"familyName"]];

        [nicknameLabel setText:welcomeText];
    }