[iphone-java] Multithreading with Cocoa
Guillaume Lecomte
guillaume86 at gmail.com
Thu Aug 7 19:23:37 UTC 2008
I'm currently reading the doc of NSThread to try to solve my problem it
should solve yours as well, if I have some good results I'll post here.
2008/8/7 Markus Heberling <markus at tisoft.de>
> Hi!
>
> I'm trying a setNeedsDisplay(), to force a repaint of the screen. It works
> fine when called from a "Native Method" like touchesMoved$withEvent$().
>
> But when I call it from my own thread, it does nothing. No error messege
> and no call of drawRect$().
>
> Could this be solved by using Foundation threads? Or is there another
> solution for forcing a repaint from outside?
>
> If this can be solved with Foundation threads, can you give a short
> example?
>
> Regards,
> Markus
>
> Am 07.08.2008 um 20:06 schrieb Guillaume Lecomte:
>
>
> Ok thank you for the response, i will take a look into Foundation threads
>> so.
>>
>> It's actually an UITableView.reloadData() that i tried but it doesn't
>> work, either with a scope.
>>
>> I'm looking forward to see jocstrap.org :)
>>
>>
>>
>> 2008/8/7 Jay Freeman (saurik) <saurik at saurik.com>
>> That isn't actually a crash condition. That just means you leaked some
>> memory.
>>
>> One thing that's weird about JocStrap (thanks for reminding me, as I need
>> to think of this as we do documentation... yes, I will have jocstrap.orgsoon setup, I'm at Linux World and have become critical to the operation of
>> the Open Voting Consortium's booth now, so I don't have as much time to do
>> IT tasks: I've been putting e-mail support first) is that you /can't/
>> directly access NSAutoreleasePool due to how the memory management works
>> (that class has special requirements that don't apply to anything else). I
>> have created joc.Scope to handle this issue.
>>
>> Additionally, Java is garbage collected, which means that resource
>> management (which this actually is as its thread-specific) must be handled
>> manually (god I miss languages like C++...). This means you need some more
>> try/catch blocks to make such code correct.
>>
>> Finally, I have no clue how well the Java thread primitives are going to
>> do for you in the long term if you intend to do anything complicated with
>> JocStrap on those threads, I'd hope they work, but everything I've so far
>> done on that matter has used Foundation threads (detachNewThread:selector:).
>>
>> new Thread(new Runnable(){
>> @Override public void run() {
>> Scope scope = new Scope(); try {
>> // do stuff
>> } finally { scope.close(); }
>> }
>> })
>>
>> I will make it so that if someone /tries/ to do that they get a nice error
>> message to the console describing what happened and pointing them to our new
>> wiki.
>>
>> -J
>>
>>
>> From: Guillaume Lecomte
>> Sent: Thursday, August 07, 2008 7:40 AM
>> To: iPhone Development in Java (JocStrap)
>> Subject: [iphone-java] Multithreading with Cocoa
>>
>> Hi,
>>
>> Does anyone knows how to call cocoa methods from a new Thread?
>> Every time the App crash with error: " _NSAutoreleaseNoPool(): Object
>> 0x4eee050 of class NSCFString autoreleased with no pool in place..." (the
>> class in the error is the class of the object i try to access)
>> The solution from :
>>
>>
>> http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/chapter_4_section_5.html#/
>> /apple_ref/doc/uid/10000057i-CH15-SW14
>>
>> http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/AutoreleasePools.html#/
>> /apple_ref/doc/uid/20000047-CJBFBEDI
>>
>> should be to create a new NSAutoreleasePool at the beginning of the Thread
>> but i have the same error if i do that.
>>
>> Snippet:
>>
>> new Thread(new Runnable(){
>> @Override
>> public void run() {
>> NSAutoreleasePool pool = new NSAutoreleasePool().init();
>> pool.release();
>> //or access to any cocoa object method
>> }
>>
>> }).start();
>>
>> Thanks in advance,
>> Guillaume
>>
>>
>> _______________________________________________
>> iPhone-Java mailing list
>> iPhone-Java at telesphoreo.org
>> http://www.telesphoreo.org/cgi-bin/mailman/listinfo/iphone-java
>>
>> _______________________________________________
>> iPhone-Java mailing list
>> iPhone-Java at telesphoreo.org
>> http://www.telesphoreo.org/cgi-bin/mailman/listinfo/iphone-java
>>
>>
>> _______________________________________________
>> iPhone-Java mailing list
>> iPhone-Java at telesphoreo.org
>> http://www.telesphoreo.org/cgi-bin/mailman/listinfo/iphone-java
>>
>
>
> _______________________________________________
> iPhone-Java mailing list
> iPhone-Java at telesphoreo.org
> http://www.telesphoreo.org/cgi-bin/mailman/listinfo/iphone-java
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.telesphoreo.org/pipermail/iphone-java/attachments/20080807/885742b8/attachment.htm
More information about the iPhone-Java
mailing list