views:

485

answers:

0

Hi,

I'm new to rubycocoa and i'm implementing an nstableView. I have saved all data to a plist file. Now when i tried to reload my data to the tableView my program becomes unresponsive and when quit it, it gives the message: No memory available to program now: unsafe to call malloc. My program stops somewhere in this method:

def tableView_objectValueForTableColumn_row(sender, aCol, rowIndex)
 return @items.objectAtIndex(rowIndex).objectForKey(aCol.identifier)    
end

here's the code before calling the two protocols:

  • tableView_objectValueForTableColumn_row(sender, aCol, rowIndex)
  • numberOfRowsInTableView(sender)

def addSettingsForCustom(sender)    
  path = OSX::NSBundle.mainBundle.pathForResource_ofType_("customData", "plist")
  newSettingsArray = OSX::NSMutableArray.arrayWithContentsOfFile(path)

  keys = OSX::NSArray.arrayWithObjects("FirstName", "Lastname", nil)
   objects = OSX::NSArray.arrayWithObjects("John", "Smith", nil)
   dict = OSX::NSDictionary.dictionaryWithObjects_forKeys_(objects, keys) 
  newSettingsArray.addObject_(dict)

  self.setDataArray(newSettingsArray)
  if !OSX::NSFileManager.defaultManager.fileExistsAtPath(path) or OSX::NSFileManager.defaultManager.isWritableFileAtPath(path)
   newSettingsArray.writeToFile_atomically_(path, true)
  end
end

and the call to setDataArray method:

def setDataArray(array)
  @items = array.retain()
end

Additional info:

I tried to removed my statements on this method: tableView_objectValueForTableColumn_row(sender, aCol, rowIndex)

and still it stops and hangs... when I turned debugger on it seems like no values was passed on this method.... It's hard to figure out why... I've checked my controller for the datasource and yes it was connected to my table...

Would appreciate your inputs.