0
シングルトンを使用してボタンの名前を保存しようとしているため、ビデオを再生するために別のビューでその名前にアクセスできます同じ名前でしかし、私はエラーを取得しています:SIGABRT。私は実際に自分のコードに何が間違っているのかは分かりません。何か案は?ここで別のビュー(Objective-C)にアクセスできるようにボタンのタイトルを保存する
#import "List.h"
#import "MyManager.h"
#import "Video.h"
@implementation ExerciseList
-(IBAction) goToVideo:(UIButton *) sender{
MyManager *sharedManager = [MyManager sharedManager];
sharedManager.vidName = [[sender titleLabel] text];
Video *videoGo = [[Video alloc] initWithNibName: @"Video" bundle: nil];
[self.navigationController pushViewController: videoGo animated: YES];
[videoGo release];
}
はMyManagerのための私の.hと.mファイルです:
#import <foundation/Foundation.h>
@interface MyManager : NSObject {
NSMutableArray *workouts;
NSString *vidName;
}
@property (nonatomic, retain) NSMutableArray *workouts;
@property (nonatomic, retain) NSString *vidName;
+ (id)sharedManager;
@end
#import "MyManager.h"
static MyManager *sharedMyManager = nil;
@implementation MyManager
@synthesize workouts;
@synthesize vidName;
#pragma mark Singleton Methods
+ (id)sharedManager {
@synchronized(self) {
if (sharedMyManager == nil)
sharedMyManager = [[self alloc] init];
}
return sharedMyManager;
}
- (id)init {
if ((self = [super init])) {
workouts = [[NSMutableArray alloc] init];
vidName = [[NSString alloc] init];
}
return self;
}
-(void) dealloc{
self.workouts = nil;
self.vidName = nil;
[super dealloc];
}
@end
も、このコードを使用することができますを保持またはコピーされていない場合MyManager' 'で' vidName'プロパティ、およびそれにアクセスしようとしたコードの宣言と実装を表示します。今はあなたがそのプロパティを設定していることを示していますが、プロパティの実装方法や、プロパティからの読み取り後の作業については何も表示されません。 –
@KurtRevis私はMyManagerの.hと.mを入れています。 –
これはOKと思われます。あなたはどこから物を読んでいるのかわかりません。また、正確にどこがクラッシュしていますか? –