【问题标题】:XMPP chat user returning nullXMPP 聊天用户返回 null
【发布时间】:2014-06-24 06:22:53
【问题描述】:

我正在使用 XMPP 实现 iPhone 聊天应用程序。我正在尝试使用以下代码获取用户对象:

       [[self appDelegate].xmppRoster addDelegate:self delegateQueue:dispatch_get_main_queue()];
       [self appDelegate].xmppRoster.autoAcceptKnownPresenceSubscriptionRequests = true;
       [self appDelegate].xmppRoster.autoFetchRoster = true;
       [[self appDelegate].xmppRoster activate:xmppStream];
       [[self appDelegate].xmppRoster fetchRoster];
XMPPUserCoreDataStorageObject *user = [[self appDelegate].xmppRosterStorage userForJID:[XMPPJID jidWithString:@"user@ip" ] xmppStream:[self appDelegate].xmppStream  managedObjectContext:[[self appDelegate] managedObjectContext_roster]]; 

但它返回 null 用户对象。

我在 tableview 控制器中获取用户列表,它工作正常。但在我试图获得特定用户的另一种观点中,它给出了一个问题。

【问题讨论】:

    标签: ios chat xmppframework


    【解决方案1】:

    我找到了解决方案。

    我添加了以下方法:

    - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller{
    } 
    

    并尝试在那里获取用户详细信息,现在它正在工作。

    【讨论】:

    • 这个方法需要在哪里添加?
    • 请在viewController中添加。请通过该函数调用您的获取用户数据函数。
    • 如果你没有得到你想要的,请分享你的代码。
    猜你喜欢
    • 2012-01-14
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 2011-11-04
    • 2017-05-25
    • 1970-01-01
    • 1970-01-01
    • 2018-02-17
    相关资源
    最近更新 更多