OGeek|极客世界-中国程序员成长平台

标题: iphone - 如何共享数据计数(Coredata 中的关系) [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:55
标题: iphone - 如何共享数据计数(Coredata 中的关系)

我有一个问题...

我有几个(2) ViewCotroller

名称分别为 ViewControllerDetailViewController

DetailViewController 有数据(Coredata 中的关系)。

这是 DetailViewController 代码。

NSSet *tags = self.bookInfo.details.tags;
tagNamesArray = [[NSMutableArray alloc] initWithCapacity:tags.count];

for (Voca_Tag *tag in tags) {
    [tagNamesArray addObject:tag.mean];
}

我想在 ViewController 中使用那个 tagNamesArray.count

还有,我被利用了

DetailViewController *detailViewController = [[DetailViewController alloc]init];

[detailViewController.tageNamesArray count];

没用。

我想在 UITableView 上使用 Count 到 cell.text。

pastebin.com/RwuR6PDt << ViewController pastebin.com/2F345vg7 << DetaulViewController

请检查...



Best Answer-推荐答案


您应该编写您的委托(delegate):在 SecondViewController.H 中:

@protocol messageDelegate <NSObject>
@optional
-(void) sendDataCountNSInteger) i;
@end
@interface SecondViewController : NSString
@property (nonatomic, assign) id <messageDelegate> delegate;
@end

在 SecondViewController.m 中:

-(void)readyToSend
{
    [self.delegate sendDataCount:__YOURCOUNT__];

}

在 ViewController.h 中:

@interface ViewController : UIViewController<messageDelegate>
@end

在 ViewController.m 中:在

- (void)viewDidLoad {
SecondViewController *secondViewController = [[SecondViewController alloc] init];
secondViewController.delegate = self;
}
-(void) sendDataCountNSInteger) i
{
    NSLog(@"Your Count  =  %d",i);
    //send Data using POST method
}

希望对您有所帮助!

关于iphone - 如何共享数据计数(Coredata 中的关系),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17851832/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4