tag question

Discussion in 'iOS Programming' started by medasmx, Mar 18, 2010.

  1. medasmx macrumors member

    Joined:
    Nov 9, 2008
    #1
    I am going through the iphone book by Mark and LaMarche, and cannot understand one segment of code. It involves the following...

    Code:
    NSNumber*tagAsNumber=[[NSNumber alloc]initWithInt:textFieldBeingEdited.tag];
    [tempValues setObject:textFieldBeingEdited.text forKey:tagAsNumber];
    
    Here is what I don't understand. It looks like you are creating a tag for the text field in the first statement. The second statement generates a key and value, using the number (tag) as the key. "tempValues" is an NSDictionary. I don't understand how the number is generated in the first statement, what that number is, etc. This code is in chapter 9 of the Mark book.

    Any help or reference is appreciated.

    Adam
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Before asking questions your first stop should be the documentation. The rag property of a UIView is well documented.

    Unless set otherwise all UIViews have a tag of 0. It is a programmer-defined identifier that can be later used to identify/retrieve specific views. I assume that you missed a step somewhere earlier in the book where the tags were set.
     

Share This Page