0

我试图从核心数据条目中提取一些值并将它们分配给 NSStrings。到目前为止,我的代码如下所示:

#import "CopyToClipViewController.h"

@interface CopyToClipViewController ()

@end

@implementation CopyToClipViewController
@synthesize device;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    if (self.device) {
        NSString *namevalue;
        NSString *versionvalue;
        NSString *companyvalue;
        [namevalue setText:[self.device valueForKey:@"name"]];
        [versionvalue setText:[self.device valueForKey:@"version"]];
        [companyvalue setText:[self.device valueForKey:@"company"]];
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

我收到错误消息,“NSString”的 No Visible @interface 声明选择器“setText:”用于尝试将数据设置为 NSString 的所有三行。任何解决方案的想法?提前致谢!

4

1 回答 1

2

写吧:

companyvalue = [self.device valueForKey:@"company"];

您不能在 NSString 上使用 setText

于 2013-11-09T18:56:44.600 回答