0

私はObjective Cが初めてで、tableviewcontrollerコード内からモデルオブジェクトに整数プロパティを設定しようとしています。モデル オブジェクト project.h の先頭は次のとおりです。

#import <Foundation/Foundation.h>
@interface Project : NSObject
@property (nonatomic) NSInteger *selecto;
@end

そして project.m は単純です

#import "Project.h"
@implementation Project
@synthesize selecto;
@end

次のように、アプリ デリゲートの didFinishLaunchingWithOptions メソッドのコードを使用して、プロジェクトのインスタンスを配列に追加しました。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
projects = [NSMutableArray arrayWithCapacity:20];
Project *project = [[Project alloc] init];
project.selecto = 0;
[projects addObject:project];
return YES;
}

tableViewControler の didselectmethod は次のとおりです。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
int selectedRow = [indexPath row];
Project *pro = [projects objectAtIndex:selectedRow] ;
*pro.selecto = 1;//errors here with exc_bad_access code=2 
}

実行するたびに、プロパティselectoの割り当てでフリーズし、エラーが発生します:exc_bad_access code = 2おそらく単純な初心者の質問ですが、これを理解するのに約8時間費やしました...おそらく別の趣味が必要です...

4

1 に答える 1