gpt4 book ai didi

ios - 无法设置属性

转载 作者:行者123 更新时间:2023-12-01 18:45:54 25 4
gpt4 key购买 nike

我正在制作博客阅读器应用。一切正常,直到我尝试从单元格访问detailView为止。我收到此错误,
[UINavigationController setPFeedURL:]: unrecognised selector sent to instance 0x7f96d5802800
下面的代码在PRTableViewController.m中

#import "PRTableViewController.h"
#import "PRFeedPost.h"
#import "PRDetailViewController.h"

这是代码发生崩溃的地方
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

if ([segue.identifier isEqualToString:@"showDetail"]){
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
PRFeedPost *feed_Post = [self.polisenFeed objectAtIndex:indexPath.row];
[segue.destinationViewController setPFeedURL:feed_Post.url];
}
}

这是为了帮助您了解我要将setPFeedURL设置为的内容。同样在PRViewTableController.m中
  self.polisenFeed = [NSMutableArray array];

NSArray *polisenFeedArray = [dataDictionary objectForKey:@"posts"];

for (NSDictionary *postDictionary in polisenFeedArray) {
PRFeedPost *fp = [PRFeedPost feedWithTitle:[postDictionary objectForKey:@"title"]];
fp.author = [postDictionary objectForKey:@"author"];
fp.thumbnail = [postDictionary objectForKey:@"thumbnail"];
fp.date = [postDictionary objectForKey:@"date"];
fp.url = [NSURL URLWithString:[postDictionary objectForKey:@"url" ]];
[self.polisenFeed addObject:fp];

}

现在是PRDetailViewController.h,

这是我要设置的属性,
@property (strong, nonatomic) NSURL *pFeedURL;
@property (strong, nonatomic) id detailItem;
@property (strong, nonatomic) IBOutlet UIWebView *webView;

这是PRDetailViewController.m中的代码,
- (void)viewDidLoad {
[super viewDidLoad];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:self.pFeedURL];
[self.webView loadRequest:urlRequest];

我似乎无法弄清楚为什么会崩溃。我知道这与这条线有关,
  [segue.destinationViewController   setPFeedURL:feed_Post.url];

(至少,我认为这是那条线。我不知道为什么无法设置它。

感谢您的帮助!

最佳答案

改变这个

PRDetailViewController *objPRDetailViewController = (PRDetailViewController *)[segue.destinationViewController topViewController]; 
objPRDetailViewController.pFeedURL=feed_Post.url;

并且还将下面的代码放在viewDidAppear中
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:self.pFeedURL];
[self.webView loadRequest:urlRequest];

关于ios - 无法设置属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35867112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com