File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes iOS and the fly likes Error because of null pointer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » iOS
Bookmark "Error because of null pointer" Watch "Error because of null pointer" New topic

Error because of null pointer

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598


I am getting the EXC_BAD_ACCESS error when I execute this code.

I think that the square object is collected so I am getting this error.
Is there any solution for this?
Thanks in advance.


My Blog SCJP 5 SCWCD 5
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I don't see square defined as a property. It looks to me like it isn't there. Maybe you have it in your interface .h file.

Anyway, if you do have it there, I don't see anywhere where square gets initialized/instantiated to actually refer to any object. So to me that means it starts off null in the beginning.

Maybe I am missing something here, but that seems to be the problem.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

It was because of improper population of the array elements.
I agree. Here's the link:
subject: Error because of null pointer
It's not a secret anymore!