Re: NSThread
Re: NSThread
- Subject: Re: NSThread
- From: Corbin Dunn <email@hidden>
- Date: Tue, 13 Jan 2015 13:09:18 -0800
> On Jan 13, 2015, at 9:57 AM, Mike Abdullah <email@hidden> wrote:
>
>
>> On 13 Jan 2015, at 16:18, Mike Abdullah <email@hidden> wrote:
>>
>>
>>> On 13 Jan 2015, at 16:07, Raglan T. Tiger <email@hidden> wrote:
>>>
>>> I allocate and init an NSThread as follows:
>>>
>>> if ( m_mythread ) [m_mythread cancel];
>>> m_mythread = [[MYThread alloc] initWithTarget:m_mythread selector:@selector(start) object:m_anobject];
>>> [m_mythread start];
>
> Looking closer, I have to wonder what you think this code will do. You seem to be trying to create a thread that will message *itself* to do its work.
Not only that, but I bet it infinite loops restarting itself.
1. Use init, not initWithTarget.
2. Override -main to do your threaded work.
corbin
> At the time this code is executed, m_mythread will either be nil, or will point to an older thread instance that you’re about to supersede.
>
> I think you need to take a step back and evaluate your app design. What are you actually trying to accomplish here? Would using NSOperationQueue or GCD better suit your needs?
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >NSThread (From: "Raglan T. Tiger" <email@hidden>) |
| >Re: NSThread (From: Mike Abdullah <email@hidden>) |
| >Re: NSThread (From: Mike Abdullah <email@hidden>) |