2011-08-26 4 views
0

私はペーストボードアイテムはペーストボードのアイテムをテーブルにコピーする方法は?

たの詳細ビューにドリルダウンし テーブルにコピーし、すべてのペーストボードアイテム、アプリケーションを作成

になっていますどこ私はここで割り当てを持っています

以下、私はRootViewController.mファイルのコードを提供します。プログラムは動作せず、この行にSIGABRTというエラーが表示されますcell.textLabel.text = cellValue;。 ここで間違っている可能性があり、事前に感謝してください。

#import "RootViewController.h" 

@implementation RootViewController 
@synthesize detailsViewController; 

NSArray* pasteBoardItems; 

- (void)viewDidLoad 
{ 
    // Get a reference to the system pasteboard 
    UIPasteboard* pasteBoard = [UIPasteboard generalPasteboard]; 

    NSLog(@"%@", pasteBoard.items); 

    pasteBoardItems = [pasteBoard.items valueForKey:@"public.utf8-plain-text"]; 
    pasteBoardItems = [pasteBoard.items valueForKey:@"public.item (kUTTypeItem)"]; 

    self.navigationItem.title = @"Pasteboard"; 

    [super viewDidLoad]; 
} 

- (void)dealloc 
{ 
    [pasteBoardItems release]; 
    [super dealloc]; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [pasteBoardItems count]; 
} 

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    NSString *cellValue = [pasteBoardItems objectAtIndex:indexPath.row]; 
    cell.textLabel.text = cellValue; 

    // Configure the cell. 
    return cell; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSUInteger row = [indexPath row]; 
    NSString *rowValue = [pasteBoardItems objectAtIndex:row]; 
    NSString *message = [[NSString alloc] initWithFormat:@"You have selected \"%@\"",rowValue]; 

    if(self.detailsViewController == nil){ 
     DetailsViewController *d = [[DetailsViewController alloc] initWithNibName:@"DetailsViewController" bundle:[NSBundle mainBundle]]; 

     self.detailsViewController = d; 
     [d release]; 
    } 
    [self.detailsViewController initWithTextSelected:message]; 
    [self.navigationController pushViewController:self.detailsViewController animated:YES]; 
} 

@end 
+0

この質問はプログラミングに関するものであり、スタックエクスチェンジにあるべきです - 私は司会者がそれを移動するようにフラグを立てています – Mark

答えて

0

SIGABRTほとんどの場合、リリースされたオブジェクトにアクセスすることを意味します。

あなたの場合は、- (void)viewDidLoadメソッドの最後に[pasteBoardItems retain];行を追加することをお勧めします。

+0

同じ問題があります – Arthur

+0

'NSLog'' pasteBoardItems'と 'cellValue'を試してみてください。そして、ここでポスト結果 – Nekto

+0

2011-09-04 19:26:27.104ダンボール[439:B303( { "public.jpeg" = "";} ) 2011-09-04 19 :26:27.109ペーストボード[439:b303]( "" ) – Arthur

関連する問題