0
  • (void)fetchLastMessageInChannel

{ __weak id weakSelf = 自己;

    for (ANKChannel *channel in self.channelArray)
    {
            NSLog(@"channels %@",channel);

             NSLog(@"channel last message %@",channel.latestMessageID);

        [[ClientManager currentClient] fetchMessageWithID:channel.latestMessageID inChannel:channel
                                               completion:^(id responseObject, ANKAPIResponseMeta *meta, NSError *error)
         {
             NSLog(@"message object %@",responseObject);
             ANKMessage *message = responseObject;

             dispatch_async(dispatch_get_main_queue(), ^{
                 [weakSelf populateTextViews:message.text];
             });

             NSLog(@"message text %@",message.text);

         }];

    }

}

-(void)populateTextViews:(NSString *)メッセージ {

NSMutableArray *textViews = [@[] mutableCopy];

NSMutableAttributedString *postText = [[NSMutableAttributedString alloc] initWithString:message];
[postText addAttributes:@{
                          NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleBody],
                          NSForegroundColorAttributeName : [UIColor darkTextColor]
                          }
                  range:NSMakeRange(0, postText.length)];

UITextView *postTextView = [[UITextView alloc] initWithFrame:CGRectMake(80, 30, kPostLabelMaxWidth, 44)];
postTextView.attributedText = postText;
postTextView.dataDetectorTypes = UIDataDetectorTypeAll;
postTextView.backgroundColor = [UIColor whiteColor];
postTextView.editable = NO;
postTextView.scrollEnabled = NO;
postTextView.clipsToBounds = NO; // So it doesn't clip the text selector

CGRect textViewBounds = postTextView.bounds;
textViewBounds.origin = CGPointMake(80, 30);
textViewBounds.size.width = MAX(textViewBounds.size.width, kPostLabelMaxWidth);
textViewBounds.size.height = postTextView.contentSize.height;


postTextView.bounds = textViewBounds;

[postTextView sizeToFit]; // Reload the content size

[textViews addObject:postTextView];



self.channelTextViewArray = [textViews copy];

}

これは、私が受けた支援を受けて、私の方法が進む限り、私が今立っている場所です. populateTextViews(NSString*) メッセージが呼び出されないため、self.channelTextViewArray は nil を返し、クラッシュを引き起こします。

何か案は?

4

1 に答える 1