Getting an error that my datasource is undefined

I have never scripted a table in studio before and I am having a little trouble. I am getting an error that my datasource is undefined and i don’t really understand the awake from nib function. I am using the table example from xcode with my on GUI. Here is the code can anyone help me?


property contactsDataSource : null

on clicked theObject
	if name of theObject is equal to "add" then
		-- Add a new contact
		set theRow to make new data row at the end of the data rows of contactsDataSource
		getContactInfo(window of theObject, theRow)
		
		-- Clear out the contact information
		clearContactInfo(window of theObject)
	else if name of theObject is "remove" then
		set tableView to table view "contacts" of scroll view "contacts" of window of theObject
		set selectedDataRows to selected data rows of tableView
		if (count of selectedDataRows) > 0 then
			tell window of theObject
				-- Remove the contact form the data source
				delete (item 1 of selectedDataRows)
				
				-- Clear out the contact information
				my clearContactInfo(window of theObject)
			end tell
		end if
		
	end if
end clicked

on selection changed theObject
	if name of theObject is "contacts" then
		set theWindow to window of theObject
		
		-- Set the contact index to the current row, so that we can use it to update the right contact later
		set selectedDataRows to selected data rows of theObject
		
		if (count of selectedDataRows) = 0 then
			-- There wasn't any selected so clear the contact information
			my clearContactInfo(theWindow)
			
			-- Disable the "Update" and "Remove" buttons
			set enabled of button "remove" of theWindow to false
		else
			-- A contact was selected, so show the contact information
			my setContactInfo(theWindow, item 1 of selectedDataRows)
			
			-- Enable the "Update" and "Remove" buttons
			set enabled of button "remove" of theWindow to true
		end if
	end if
end selection changed

on awake from nib theObject
	(*Add your script here.*)
	set contactsDataSource to make new data source at end of data sources with properties {name:"name"}
	set data source of theObject to contactsDataSource
end awake from nib

on will open theObject
	-- Set up the contactDataSource so that the rest will be simpler
	set contactsDataSource to data source of table view "contacts" of scroll view "contacts" of theObject
	
	-- Here we will add the data columns to the data source of the contacts table view
	tell contactsDataSource
		make new data column at the end of the data columns with properties {name:"name"}
		
	end tell
end will open

(* ==== Contact Handlers ==== *)

-- Empty all of the text fields
--
on clearContactInfo(theWindow)
	tell theWindow
		set contents of text field "name" to ""
		set first responder to text field "name"
	end tell
end clearContactInfo

-- Get the values from the text fields and set the cells in the the data row
--
on getContactInfo(theWindow, theRow)
	tell theWindow
		--set contents of data cell "name" of theRow to contents of text field "name"
		set contents of cell "name" of newRow to contents of text field "name" of window "with" as string
		
	end tell
end getContactInfo

-- Set the text fields with the values from the contact
-- 
on setContactInfo(theWindow, theRow)
	tell theWindow
		--set contents of text field "name" to contents of data cell "name" of theRow
		set contents of cell "name" of newRow to contents of text field "name" of window "with" as string
	end tell
end setContactInfo

THANKS!!

I figured it out. I need to make a cocoa-applescript datasource. It is working good now.