objective c - SLTwitterComposeViewController message sent to deallocated instance -


i'm working on cocos2d project on ios6 , crash time time while i'm trying share on twitter.

  • it only crashes on physical device (ios 6.1.3)
  • it runs without problems on simulator (ios 6.1)
  • the problem arises when [twitterviewcontroller addimage:] used
  • i'm using arc
  • update: problem \n character on body

when call shareontwitter function, opens twitter share. can close or post , dismiss view fine. second, third or more times press button crash exc_bad_access.

with enable zombie objects error:

[sltwittercomposeviewcontroller respondstoselector:]: message sent deallocated instance

it not crash on particular line on code.

stack:

libobjc.a.dylib`objc_msgsend: 0x3ad3b5a0:  teq.w  r0, #0 0x3ad3b5a4:  beq    0x3ad3b5e6                ; objc_msgsend + 70 0x3ad3b5a6:  push.w {r3, r4} 0x3ad3b5aa:  ldr    r4, [r0] 0x3ad3b5ac:  lsr.w  r9, r1, #2 0x3ad3b5b0:  ldr    r3, [r4, #8]    <-------- thread 1: exc_bad_access 0x3ad3b5b2:  add.w  r3, r3, #8 0x3ad3b5b6:  ldr    r12, [r3, #-8] 0x3ad3b5ba:  and.w  r9, r9, r12 0x3ad3b5be:  ldr.w  r4, [r3, r9, lsl #2] 

code:

- (void)shareontwitter {      uiimage *renderedimage = ...;      nsstring *text = ...;      slcomposeviewcontroller *twitterviewcontroller = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypetwitter];     [twitterviewcontroller setinitialtext:text];     [twitterviewcontroller addimage:renderedimage];     [twitterviewcontroller addurl:[nsurl urlwithstring:kappurl]];     [twitterviewcontroller setcompletionhandler:^(slcomposeviewcontrollerresult result){          switch (result) {             case slcomposeviewcontrollerresultcancelled:                 break;             case slcomposeviewcontrollerresultdone:                 break;             default:                 break;         }          [[ccdirector shareddirector] dismissviewcontrolleranimated:yes completion:nil];     }];      [[ccdirector shareddirector] presentviewcontroller:twitterviewcontroller animated:yes completion:nil]; } 

thanks help!

update:

the problem solved when comment line adds image:

//[twitterviewcontroller addimage:renderedimage]; 

which made me doubt render image function, replaced line with:

[twitterviewcontroller addimage:[uiimage imagenamed:@"icon@2x.png"]]; 

and problem noticeable once again. weird right?

finally got it! problem return character on message text. weird seems occurs text lenght , parameters sets.

took me few hours close problem , make example produces app crash. crashes in circumstances. example, text i'm providing, if comment addurl not crash.

pay attention setinitialtext in following code, @ end of text there \n character. tiny problem...

[twitterviewcontroller setinitialtext:@"########################## ###########? ########### ########: #######\n## #######"]; [twitterviewcontroller addurl:[nsurl urlwithstring:@"http://google.com"]]; 

now, if replace lines on same code in question, application crash after twitter view dismisses.

i created new project , paste same lines... crashes. may bug on slcomposeviewcontroller


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -