• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Threading issues with ivars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threading issues with ivars


  • Subject: Re: Threading issues with ivars
  • From: Peter Blazejewicz <email@hidden>
  • Date: Tue, 2 Feb 2010 14:16:26 +0100

Hi Andreas,
You're not clearing "text" - you're clearing UILabel reference in your code:

self.nameLabel = nil;

If you wan't to reset just text then: self.nameLabel.text = @"";
(or any way you prefer depending on UI requirements),

With your current code you just sending message to nameLabel = which
is actually nil in your -(void)updateLabels method,
regards,
Peter Blazejewicz

On Tue, Feb 2, 2010 at 1:49 PM, Andreas Grosam <email@hidden> wrote:
> Hello,
>
> I have the following issue:
>
>
> There is a label "nameLabel" which text needs to be set from a certain field in the dictionary.  I don't want to set the label's text property directly in the main thread's method - instead I use an NSString instance called "name" to store the text. This is an ivar, see property declaration below.
> Before the thread is finished and returns, it schedules the method -upadateLabels on the main thread which finally sets the label's text property  (shown below).
>
>
>
>
> - (void) updateLabels
> {
>    self.nameLabel.text = self.name;
> }
>
>
>
> One *important* observations is here:
> Before generating the URL request, I actually need a parameter which is asked from the user via an interface.
> When the user starts to edit the input (a UITextField) the view controller gets notified through a method, shown below.
> The purpose of this method is to clear the previous results.
>
> ** IFF I do not set the text property to nil, the NSString instance "name" remains valid. So, it seems, that the string object will be *shared* - but not copied. Hence the auto release pool does not dealloc the string. The label's text property is declared as: @property(nonatomic, copy) NSString* text
> This looks strange to me. Any thoughts?
>
>
> - (void)textFieldDidBeginEditing:(UITextField *)textField
> {
>    // User entered editing: clear labels:
>    self.nameLabel = nil;  // if uncommented, the ivar "name" remains valid
> }
>
> _______________________________________________
>
> 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

  • Follow-Ups:
    • Re: Threading issues with ivars
      • From: Andreas Grosam <email@hidden>
References: 
 >Threading issues with ivars (From: Andreas Grosam <email@hidden>)

  • Prev by Date: Re: Threading issues with ivars
  • Next by Date: Re: Threading issues with ivars
  • Previous by thread: Re: Threading issues with ivars
  • Next by thread: Re: Threading issues with ivars
  • Index(es):
    • Date
    • Thread