Discussion Forums  >  Xcode, Errors, Installing, Configuring

Replies: 12    Views: 143

Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
11/01/12 05:01 AM (13 years ago)

Use of undeclared identifier

Hi there, I am attempting to create a countdown widget in my app. Using the blank screen plugin, I am trying out the code provided on this website. http://iphoneapp-dev.blogspot.it/2010/10/how-to-create-countdown-timer-in-iphone.html#comment-form I am getting an error “use of undeclared identifier” and “unused variable" My guess is this code was written in pre 4.5 days so some modification is required? Any thoughts anyone? I am not even sure if this is a reliable site, but I thought it was worth a try. Here’s a couple of screenshots from Xcode of what happens when I use this code. https://www.dropbox.com/sh/uujlnafwdf5lstw/OarysZ9Yuj
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
11/01/12 05:34 AM (13 years ago)
you might need to declare those three variables in your .h file (@property), and synthesize them in the .m file.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
11/01/12 10:01 AM (13 years ago)
Hi @Dervalo, I agree with @Stobe with your files. LA
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/01/12 10:23 AM (13 years ago)
Not really sure how to do that… Is it something like this: for h file: @property (nonatomic) int secondsLeft; @property (nonatomic) int minutes; @property (nonatomic) int hours; @property (nonatomic) int seconds; ..and for m.file? @synthesize secondsLeft; @synthesize hours; @synthesize minutes; @synthesize seconds;
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
11/01/12 10:26 AM (13 years ago)
yes, but for the @synthesize, you can string them together on one line @synthesize secondsLeft, hours, minutes, seconds; (same result - just less typing)
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/01/12 12:21 PM (13 years ago)
no more red errors… just yellow: Local declaration of 'secondsLeft' hides instance variable and unused variables hours, minutes and seconds (this one was there the last time too). Can you help? Thanks
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
11/01/12 12:29 PM (13 years ago)
I'd probably have to see more screenshots. But in the last ones, it looks like you had "_secondsLeft" some places and "secondsLeft" in other places. Was that intentional?
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/01/12 01:23 PM (13 years ago)
https://www.dropbox.com/sh/uujlnafwdf5lstw/OarysZ9Yuj Here’s a couple more screenshots. I had originally tried _secondsLeft but when it didn’t work, I removed them. Thanks again for taking a look… much appreciated.
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/03/12 11:15 AM (13 years ago)
The folks at Stackoverflow advised that I should get rid of these lines from your "viewDidLoad" function: int hours, minutes, seconds; int secondsLeft; Those two lines are what's generating the "local declaration hides instance variable" errors and use "self." in front of any properties being referenced. This got rid of all warnings. I guess it’s time to upgrade my account to see if this countdown timer plugin actually works!
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/03/12 11:59 AM (13 years ago)
… that’s what I need to do right? I guess I can’t just use the blank screen plugin and expect the code to do what it’s supposed to, right? Thanks :-)
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/03/12 12:05 PM (13 years ago)
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
11/03/12 12:17 PM (13 years ago)
I've never used the blank screen plugin. But I think to do what you want to, you'd have to use the plugin creator tool to create a custom class for your new timer screen to "work" within. And for that, I think you do need to upgrade. If you haven't watched David's "Lets make a plugin" video yet, I'd suggest watching that to see how that all works.
 
Derval
Aspiring developer
Profile
Posts: 364
Reg: Sep 20, 2012
Milan
17,240
like
11/03/12 12:23 PM (13 years ago)
@Stobe - thanks a lot for your help!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.