1

In my app, when I press a button the method called for that button first assigns my textfield texts directly to NSArray object like:

 val = [[NSArray alloc] initWithObjects: nameText.text, cellText.text, p_emText.text, 
                                      p_cnfrmText.text, s_emText.text, s_cnfrmText.text,
                                      emailText.text, ecnfrmText.text, lat, longt,  
                                      nil];

when I run my app on simulator no app crashing occurs, but when I run it on my iPhone device it gives: Thread 1: program recieved signal "EXC_BAC_ACCESS"

Can anybody tell why this happens and what's the solution for this scenario?

Najeebullah Shah
  • 4,164
  • 4
  • 35
  • 49

5 Answers5

2

In XCode, go to menu "edit scheme", choose the running configuration and add 'NSZombieEnabled' like in the picture below, when your apps crashes, it will provide you additional infos on the crash that should help you debug it.

enter image description here

EDIT

Note that when your application debug is over, remove the NSZombieEnabled command as it impacts the application performances

Niko
  • 2,543
  • 1
  • 24
  • 29
  • 2011-12-08 14:18:41.670 DMFoundation[1750:707] *** -[CFString retain]: message sent to deallocated instance 0x1ed4b0 I got this message by doing what you recommended – Najeebullah Shah Dec 08 '11 at 09:20
1

All objects involved in array creation using initWithObjects should be actual objects. There is no enough code in your question to know if lat and longt are objects too. Are they?

If they aren't, wrap them with [NSNumber numberWithFloa:<# the float #>].

If that's not the problem, check SO questions regarding EXC_BAC_ACCESS to learn to debug them.

djromero
  • 19,551
  • 4
  • 71
  • 68
0

Most probably your app is crashing due to memory issues since it is not crashing in simulator, try to release all objects that you allocate at the points you are done with them.

If you have your custom objects which you allocate and initialize as;

MyCustomClass *myObject = [[MyCustomClass alloc] init];

you need to release them as

[myObject release];

especially if they have members which are assigned big sized images or other kind of data.

If your app starts to crash less after you start solving these memory management issues, it shows that you are on the right way. So keep releasing.

onuryilmaz
  • 378
  • 1
  • 4
  • 9
0

Delete the app from simulator/ delete the build file from Mac/ clean the product from XCode and then again run it in simulator. Check if it crashes in simulator now.

Take a look at this link : EXC_BAD_ACCESS signal received. Also, Take NSLog of all the textfield.texts before putting them in array. May be one of them has become nil.
Community
  • 1
  • 1
utsabiem
  • 920
  • 4
  • 10
  • 21
  • my app doesn't crash on simulator, it only crashes with the signal when i run it on my iphone device – Najeebullah Shah Dec 08 '11 at 07:47
  • Good for you. Did you take the logs of the textfields ? You must know that BAD_ACCESS is a crash related to memory issue. – utsabiem Dec 08 '11 at 07:49
  • As the view loads i m putting @""; in all the textfield texts so there will never be a nil assigned to any of the textfield text. I have released val (where signal is recieving) at the end of the method, still issue is not resolved – Najeebullah Shah Dec 08 '11 at 08:27
  • `2011-12-08 14:18:41.670 DMFoundation[1750:707] *** -[CFString retain]: message sent to deallocated instance 0x1ed4b0 I got this message by doing what you recommended` Clearly some string issue. Some string got deallocated somehow. – utsabiem Dec 08 '11 at 09:28
0

it may be a case of memory managemnet...have you released all the objects after their use?

simulator has the memory space of whole of the machine...but iphone has a defined memory of a sandbox for a single app.

nikita21
  • 111
  • 1
  • 5
  • i am allocating memory to val whenever the button is pressed, and at the end of the method of that button i m releasing the val as: [val release]; still am having problem – Najeebullah Shah Dec 08 '11 at 09:26