title: Molecules variables are nil?
body: <p>I am new to Objective-c and I am having a bit of a problem. My code seems to check out since xcode says i have no issues, but upon building it says all my variables in Molecule are nil. I can't seem to figure it out. Let my know if posting my element class is necessary and thanks. I am open to any corrective criticism and willing to learn.</p>
  
  <p>Here is main.m</p>
  
  <pre><code>@autoreleasepool {
  
      // insert code here...
      Element *myElement1 = [[Element alloc] initWithName:@"Hydrogen" andSymbol:@"H" andAtomicNumber:1 andAtomicWeight:1.00794];
      NSLog(@"The element %@ has atomic number %li.", [myElement1 name], (long)[myElement1 atomicNumber]);
  
      NSLog(@"The element is %@.", [myElement1 description]);
  
      Element *myElement2 = [[Element alloc] initWithName:@"Hydrogen" andSymbol:@"H" andAtomicNumber:1 andAtomicWeight:1.00794];
  
      NSLog(@"The element is %@.", [myElement2 description]);
  
      NSLog(@"The element %@ has atomic number %li.", [myElement2 name], (long)[myElement2 atomicNumber]);
  
      Element *myElement3 = [[Element alloc] initWithName:@"Oxygen" andSymbol:@"O" andAtomicNumber:8 andAtomicWeight:15.9994];
  
      NSLog(@"The element is %@.", [myElement3 description]);
  
      NSLog(@"The element %@ has atomic number %li.", [myElement3 name], (long)[myElement3 atomicNumber]);
  
  
  
      Molecule *myMolecule = [[Molecule alloc] initWithName:@"Water" andSymbol:@"H2O" andElement1:myElement1 andElement2:myElement2 andElement3:myElement3 andWeight:33.00674];
  
      NSLog(@"The molecule is %@.", [myMolecule description]);
  
      NSLog(@"The molecule %@ has symbol %@ and atomic number %li.", [myMolecule name], [myMolecule symbol],(long)[myMolecule weight]);
  
  
  
  }
  return 0;
  
  }
  </code></pre>
  
  <p><strong>here is Molecule.h</strong></p>
  
  <pre><code>@interface Molecule : NSObject{
  
  NSString *name;
  NSString *symbol;
  Element *element1;
  Element *element2;
  Element *element3;
  float weight;
  
  }
  
  -(id)init;
  -(id)initWithName:(NSString *)newName;
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol;
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element         *)newElement1;
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element   *)newElement1 andElement2:(Element *)newElement2;
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element *)newElement1 andElement2:(Element *)newElement2 andElement3:(Element *)newElement3;
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element  *)newElement1 andElement2:(Element *)newElement2 andElement3:(Element *)newElement3 andWeight:      (float)newWeight;
  
  -(void)setName:(NSString *)newName;
  -(NSString *)name;
  -(void)setSymbol:(NSString *)newSymbol;
  -(NSString *)symbol;
  -(void) setElement1:(Element *)newElement;
  -(Element *)element1;
  -(void) setElement2:(Element *)newElement;
  -(Element *)element2;
  -(void) setElement3:(Element *)newElement;
  -(Element *)element3;
  -(void)setWeight:(float) newWeight;
  -(float)weight;
  
  -(NSString *)description;
  
  @end
  </code></pre>
  
  <p><strong>Here is Molecule.m</strong></p>
  
  <pre><code>@implementation Molecule
  -(id)init
  {
  return [self initWithName:@"No Name"];
  }
  
  -(id)initWithName:(NSString *)newName
  {
      return [self initWithName:newName andSymbol:@"?"];
  }
  
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol
  {
      return [self initWithName:newName andSymbol:newSymbol andElement1:element1];
  }
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element *) newElement1
  {
      return [self initWithName:newName andSymbol:newSymbol andElement1:element1 andElement2:element2];
  }
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element *) newElement1 andElement2:(Element *) newElement2
  {
      return [self initWithName:newName andSymbol:newSymbol andElement1:element1 andElement2:element2 andElement3:element3];
  }
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element *) newElement1 andElement2:(Element *) newElement2 andElement3:(Element *)newElement3
  {
      return [self initWithName:newName andSymbol:newSymbol andElement1:element1 andElement2:element2 andElement3:element3 andWeight:0.0];
  }
  
  // Designated Initializer
  -(id)initWithName:(NSString *)newName andSymbol:(NSString *)newSymbol andElement1:(Element *)newElement1  andElement2:(Element *)newElement2 andElement3:(Element *)newElement3 andWeight:(float)newWeight
  {
      self = [super init];
      if (self) {
          [self setName:newName];
          [self setSymbol:newSymbol];
          [self setElement1:element1];
          [self setElement2:element2];
          [self setElement3:element3];
          [self setWeight:newWeight];
      }
      return self;
  }
  
  -(void)setName:(NSString *)newName
  {
      name = newName;
  }
  -(NSString *)name
  {
      return name;
  }
  -(void)setSymbol:(NSString *)newSymbol
  {
      symbol = newSymbol;
  }
  -(NSString *)symbol
  {
      return symbol;
  }
  -(void)setElement1:(Element *)newElement1
  {
      element1 = newElement1;
  }
  -(Element *)element1
  {
      return element1;
  }
  
  -(void)setElement2:(Element *)newElement2
  {
     element2 = newElement2;
  }
  -(Element *)element2
  {
      return element2;
  }
  -(void)setElement3:(Element *)newElement3
  {
      element3 = newElement3;
  }
  -(Element *)element3
  {
      return element3;
  }
  -(void)setWeight:(float)newWeight
  {
      weight = [element1 atomicWeight]+ [element2 atomicWeight]+ [element3 atomicWeight];
  }
  -(float)weight
  {
      return weight;
  }
  
  
  
  -(NSString *)description
  {
      return [NSString stringWithFormat:@"\nName : %@\nSymbol: %@\nElement1 :%@\nElement2 :%@\nElement3 : %@\nWeight : %f\n", name, symbol, element1, element2, element3, weight];
  }
  
  
  
  
      @end
  </code></pre>
  
  <p>My output is:</p>
  
  <pre><code>2014-01-28 12:33:53.166 MyFirstApp[14239:303] The element Hydrogen has atomic number 1.
  2014-01-28 12:33:53.168 MyFirstApp[14239:303] The element is 
  Name : Hydrogen
  Symbol: H
  Atomic Number : 1
  Atomic Weight : 1.007940
  .
  2014-01-28 12:33:53.168 MyFirstApp[14239:303] The element is 
  Name : Hydrogen
  Symbol: H
  Atomic Number : 1
  Atomic Weight : 1.007940
  .
  2014-01-28 12:33:53.168 MyFirstApp[14239:303] The element Hydrogen has atomic number 1.
  2014-01-28 12:33:53.169 MyFirstApp[14239:303] The element is 
  Name : Oxygen
  Symbol: O
  Atomic Number : 8
  Atomic Weight : 15.999400
  .
  2014-01-28 12:33:53.169 MyFirstApp[14239:303] The element Oxygen has atomic number 8.
  (lldb)
  </code></pre>
  
  <p>This is what's in variables view</p>
  
  <pre><code>myElement2  Element *   0x10010d610 0x000000010010d610
  myElement3  Element *   0x100300340 0x0000000100300340
  myElement1  Element *   0x100102e90 0x0000000100102e90
  myMolecule  Molecule *  nil 0x0000000000000000
  NSObject    NSObject        
  name    NSString *  nil 
  symbol  NSString *  nil 
  element1    Element *   nil 
  element2    Element *   nil 
  element3    Element *   nil 
  weight  float        
  </code></pre>