2012-02-18 3 views
1
내가

sharekit :: EXC_BAD_ACCESS @의 shareItem

... 
// --- add the mail button ------------------------------------ 
UIButton *buttonMail = [UIButton buttonWithType:UIButtonTypeCustom]; 
buttonMail.frame = CGRectMake(0,0, btnW, btnH); 
[buttonMail setImage:[UIImage imageNamed:@"btn_mail.png"] forState:UIControlStateNormal]; 
[buttonMail addTarget:self action:@selector(sendPerMailEvent:) forControlEvents:UIControlEventTouchUpInside]; 
... 

     // the sharekit image object 
     item = [SHKItem image:image title:@"Name of the image" ]; 
     item.text = @"some text..."; 
     [SHK setRootViewController:self.webView.window.rootViewController]; 
... 

-(void)sendPerMailEvent:(id)sender {  
    [SHKMail shareItem:item]; 
    [self closeScreenshotView]; 
} 

하지만 내 자신의 버튼을 actionSheet을 사용하고 있지만 사용하지 않고 shareKit의 도움으로 이미지를 보내려고

난을 클릭하면

+ (id)shareItem:(SHKItem *)i 
{ 
    [SHK pushOnFavorites:[self sharerId] forType:i.shareType]; // -> EXC_BAD_ACCESS 
: 버튼 엑스 코드는 shareItem()의 첫 번째 줄에 나에게 " EXC_BAD_ACCESS"오류를 던지고있다

나는 objective-c에 새로 왔으며 app는 phonegap을 사용하여 만들어졌다. thnx!

+0

이미지를 가져온 SHKItem에 항목을 설정할 때? 나는 그것을 초기화하기 전에 [SHKItem image : image title : @ "이미지의 이름"]; – xanderer

+0

이미지가 있고 기다리고 있습니다 : 'UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); ... image = [[UIImage alloc] initWithCGImage : image.CGImage scale : 1.0f orientation : UIImageOrientationLeft]; ' 내 .h 파일에서'@interface MyPlugIn : PGPlugin {NSString * callbackID ; SHKItem * 항목; } @property (nonatomic, copy) NSString * callbackID; ' – headkit

답변

0

지금은 발견 : 나는 [item retain]을 추가 할 필요를 먹으 렴 .

1

먼저 EXC_BAD_ACCESS 신호가 나오면 삭제 된 개체에 액세스하려고한다는 메시지가 표시됩니다.

& 개체를 초기화하지 않은 것처럼 보입니다. 필요한 개체가 출시되기 전에 해제됩니다.

SHKItem* item = [SHKItem alloc] init] 
[item seTitle:@"Name of the image"]; 

을하고 당신은 여전히이 문제를 얻을 수 있는지 여부를 확인 :

이보십시오. 앞으로

당신이 EXC_BAD_ACCESS이 link here

둘째 NSZombieEnabled 환경 켜십시오 얻을 경우. 당신은 당신에게 당신이있어 EXC_BAD_ACCESS을 제공하는 클래스의 할당 해제의 방법을 무시하고 사용을 할당 해제되는 것을 보여주기 위해 스택 트레이스를 인쇄 할 수 있습니다

NSLog(@"I've been dealloced by: %@",[NSThread callStackSymbols]); 
+0

내 .h 파일에서'@interface MyPlugIn : PGPlugin { NSString * callbackID; SHKItem * item; } @property (nonatomic, copy) NSString * callbackID;'. 이게 잘못한거야? – headkit

+0

작동하지 않습니다 ... :-( – headkit