ios - Retrieving data in a Core Data Relationship -


i working on project provides way collect data rooms @ specific address. have set relationship in data model between rooms , address tables. project presents uitableview of addresses user able drill down via address uitableview view rooms.

this clueless. if there no rooms, custom uiview presented enter room data. user enters data in uiview each data point , presses save. ibaction save button sets value each key in related table. assuming here need establish relationship between address , rooms, cannot find proper way this. have tried nsset setwithobject in setvalue method:

[newroom setvalue:[nsset setwithobject:_address] roomname.text forkey:@"roomname"]; 

but xcode wants me insert colon between roomname , text.

ultimately want user able choose address , manage room data address, unsure how establish relationship between address , rooms.

any appreciated.

it sounds address room relationship 1 many: each address can have many rooms, whereas each room relates 1 address. address entity should have rooms property represent relationship, , room entity should likewise have address property. (if have used different names these properties, amend below necessary).

when user selects row in table view of addresses, determine corresponding address object. let's call chosenaddress. second table view should display room objects relate chosenaddress. when create new room object, let's call newroom, can establish relationship chosenaddress with:

[newroom setvalue:chosenaddress forkey:@"address"]; 

or, if have created nsmanagedobject subclasses address , room:

newroom.address = chosenaddress; 

note coredata automatically set inverse relationship, adding newroom set given chosenaddress.rooms.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -