Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Can someone help me figure this out? :)

Can someone help me figure this out? :)
Thread Tools
Forum Regular
Join Date: Aug 2005
Status: Offline
Reply With Quote
Feb 14, 2006, 10:48 PM
 
Sorry for the thread topic, I couldn't think of anything better

I am trying to learn Cocoa and wanted to create a simple program that has a button and an NSTextField. When the button is pressed I wanted text to fill the NSTextField by scrolling into it. Anyway, here is the code from the Class I created to control the window.

- (IBAction)startid)sender
{

[NSTimer scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(changeText)
userInfo:self
repeats:YES];


}

- (void)changeText
{

NSString *textStringData = @"Scrolling Text";
NSMutableString *intermediateStringData
int stringLength = [textStringData length];
int x;
for (x = 0; x < stringLength; x++)
{
[intermediateStringData characterAtIndex:x] = [textStringData characterAtIndex:x];
[textField1 setStringValue: intermediateStringData];
}

}
@end

I get four build errors:

-Nested functions are not supported on MacOSX for the line "int stringLength = [textStringData length];

-'stringLength' undeclared for the line "for (x = 0; x < stringLength; x++)"

-'intermediateStringData' undeclared for the line "[intermediateStringData characterAtIndex:x] = [textStringData characterAtIndex:x];"


I am new, so please be gentle
YummySoup! - Recipe management and sharing at its best!
     
Forum Regular
Join Date: Aug 2005
Status: Offline
Reply With Quote
Feb 14, 2006, 10:53 PM
 
Hrmm... I just realized that aside from the problems that I am having with the code, I am guessing that the NSTimer I have will keep resetting the "for" loop and will keep redrawing the first letter over and over. Darn
(Last edited by HungrySeacow; Feb 14, 2006 at 11:20 PM. )
YummySoup! - Recipe management and sharing at its best!
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Feb 15, 2006, 01:48 AM
 
You're missing a semicolon.

As for the loop: It sounds like what you want is an instance variable that keeps track of where you are in the string between calls rather than a loop.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
Forum Regular
Join Date: Aug 2005
Status: Offline
Reply With Quote
Feb 16, 2006, 06:56 PM
 
Ahh, yes semicolon was missing. I think I am going to go back to reading Cocoa Programing For OS X, by Aaron Hillegass for a while before I continue on this one.
YummySoup! - Recipe management and sharing at its best!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:29 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2