0

I declare "int x" in view A and in view B but occur below error Why?

Duplicate symbol -X in...
  • You might want to post a bit more code here; there's not really enough to go on. – Ben Gottlieb Oct 04 '10 at 13:24
  • Provide more info... Check this one http://stackoverflow.com/questions/1908222/obj-c-duplicate-symbol-for-header-variable – RK- Oct 04 '10 at 13:27
  • Accept the answers for your other questions, otherwise people would not be interested in answering your questions. – RK- Oct 04 '10 at 13:32
  • i declare "int x=0" under @implementation A and @implementation B Why does it joint in two views? –  Oct 04 '10 at 13:46
  • 2
    "more code" actually means "more code" since, according to your description, your code will run fine. And please edit your post, rather than use the comments for additional information. Also, you should still accept some answers or you might not get one here anyway. – Philipp Schlösser Oct 04 '10 at 13:53

1 Answers1

1

If you've declared this int variable outside of an interface section, and outside of any method in an implementation section, you've declared a global variable.

A global variables is accessible across an entire app, and can only be declared once (other than as an extern reference) in one place.

If you don't want a global variable, but an object instance variable, declare it inside your interface definition brackets.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153