Hi,
I am used to be a GNU/Linux & PHP programmer but now I have an Iphone project.
I have a game scene needing to load some numbers from the internet. If I directly send messages to my InternetUtils Class the interface will be unresponsible until an answer.(is this normal behaviour?) So I want to send a message to a internet thread, changing one label after receiving the data.
I pass the scene to the thread and if the thread changes the string, the label acts unexpected, it becomes a white box.
Shorted Code:
GameScene
...
[NSThread detachNewThreadSelector:@selector(calculateLabel:) toTarget:[InternetUtils class] withObject:self];
Thread:
@implementation InternetUtils
+(void)calculateLabel:(GuessScene*)scene{
id p =[NSAutoreleasePool new];
bestWord = @"builded from more code";
[scene.GuessingWord setString:bestWord];
[p release];
}
@end
Does someone know what is wrong with this code?
And do I need to add special steps to end the thread?
Generally: Are there any greater examples/guidelines about the organisation of the code? Should be game logic added to scenes or other objects?
Cheers
jogo