// perform selector after delay
[self performSelector:@selector(ClearLabel) withObject:nil afterDelay:2];
}
- (void)ClearLabel
{
label.text = @"";
}
I want to get rid of the Array of words and get my program to pull a Random word from a text file instead. That way when I need to update the App with more vocabulary I can just update a text file instead.
// perform selector after delay
[self performSelector:@selector(ClearLabel) withObject:nil afterDelay:2];
}
- (void)ClearLabel
{
label.text = @"";
}
I want to get rid of the Array of words and get my program to pull a Random word from a text file instead. That way when I need to update the App with more vocabulary I can just update a text file instead.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I put [self buildRandomWordArray]; in view did load because it only needs to be called once.
-(IBAction)randomWord {
[self getRandomWord];
label.text = result;
}
error: 'result' undeclared (first use in this function)
At top level:
warning: property 'words' requires method '-words' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'words' requires the method 'setWords:' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'randomArray' requires method '-randomArray' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'randomArray' requires the method 'setRandomArray:' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'array' requires method '-array' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'array' requires the method 'setArray:' to be defined - use @synthesize, @dynamic or provide a method implementation
Dude,
I'm not teaching a one-on-one free class in remedial Objective C. I wrote the post I referred to assuming a basic level of knowledge.
You are making tons of mistakes that show me that you have no idea how to program for iOS.
The method getRandomWord returns a string object. You have to do something with that returned value. There is no variable "result" unless you declare one.
All the errors about properties are telling you exactly what you need to do. You need to add @synthesize statements for all the properties you declare, or write custom getter/setter methods. In this case, just add @synthesize statements.
Download the Objective C 2.0 reference from Apple site and read it. Do a search on @synthesize and find where it is supposed to go in your code.
You may also want to buy a book on beginning iOS development. There is a sticky thread at the top of this forum on recommended iOS books.
If you can't figure out the documentation, take a look at one of Apple's sample applications that are included with the SDK. Search in the XCode docs for HelloWorld. The app delegate and the view controller in that program both declare a couple of properties and use @synthesize.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I put [self buildRandomWordArray]; in view did load because it only needs to be called once.
-(IBAction)randomWord {
[self getRandomWord];
label.text = result;
}
error: 'result' undeclared (first use in this function)
At top level:
warning: property 'words' requires method '-words' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'words' requires the method 'setWords:' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'randomArray' requires method '-randomArray' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'randomArray' requires the method 'setRandomArray:' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'array' requires method '-array' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'array' requires the method 'setArray:' to be defined - use @synthesize, @dynamic or provide a method implementation
I @synthesize all the variables in the warnings above.
With the following IBACTION
-(IBAction)randomWord {
NSString* result;
result = [self getRandomWord];
label.text = result;
}
When the user clicks the button once every word in my Words.txt file appears in the label. When the user clicks the button again nothing happens. So I modified it to the following:
I @synthesize all the variables in the warnings above.
I don't understand that sentence. Post the code that includes the @synthesize statements. If you have them in the right place, you won't get the warnings you posted.
Quote:
With the following IBACTION
-(IBAction)randomWord {
NSString* result;
result = [self getRandomWord];
label.text = result;
}
When the user clicks the button once every word in my Words.txt file appears in the label. When the user clicks the button again nothing happens. So I modified it to the following:
Now every time the user clicks the button the whole contents of my words.txt file is display in my label without in formating. Any suggestions.
The code I posted is written assuming each word is on a separate line in your text file. If you just have a text file
"word word word word word" then you will get everything as one "word"
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
When the user clicks the button once every word in my Words.txt file appears in the label. When the user clicks the button again nothing happens.
What do you mean every word appears? Do they appear one at a time on top of each other in rapid succession? Do you have a really long label and you see all the words one right after another?
[QUOTE
Now every time the user clicks the button the whole contents of my words.txt file is display in my label without in formating. Any suggestions.[/quote]
Again, what do you mean the whole contents appears? Are they smooshed together with no spaces so you can see them all?
What event do you have connected your action method? You want to use touch up inside. That way the action doesn't get triggered until you release the button. Some of the other events might trigger the action to be triggered repeatedly. I'd have to look through the list of events to see which ones might fire repeatedly for a single press.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
I have a long *** label. At the the current font size of the label every word of the Array appears in the label. One ling, every word one after another. So this is my txt file
ANT
BAT
CAT
DOG
FAT
GUT
HIT
INK
JET
KNOT
LIKE
MAN
NOT
OX
PAT
MIX
RAT
SIT
TIN
IT
VENT
WET
FIX
YAK
ZEBRA
HAT
AX
SAT
FAX
FIT
MILK
HAIR
LION
and here is the result when the user clicks the button.
ANTBATCATDOGFATGUTHITINKJETETC. If I increase the font size of the label some words get cut off. Only one word is suppose to be displayed.
I have a long *** label. At the the current font size of the label every word of the Array appears in the label. One ling, every word one after another. So this is my txt file
ANT
BAT
CAT
DOG
FAT
GUT
HIT
INK
JET
KNOT
LIKE
MAN
NOT
OX
PAT
MIX
RAT
SIT
TIN
IT
VENT
WET
FIX
YAK
ZEBRA
HAT
AX
SAT
FAX
FIT
MILK
HAIR
LION
and here is the result when the user clicks the button.
ANTBATCATDOGFATGUTHITINKJETETC. If I increase the font size of the label some words get cut off. Only one word is suppose to be displayed.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.