PDA

View Full Version : Objective C Core




teguh123
Apr 4, 2011, 10:47 PM
This is a rough VB.net object I want to translate.

Class Restaurant
Public Property Title As String
Public Property BuildingAddress As String
Public Property Street As String
Public Property Districts As Generic.List(Of String)
Public Property City As String
Public Property Country As String

Public Property LatitudeLongitude As LatitudeLongitude
Public Property Rating As Rating
Public Property imageUrls As Generic.List(Of String)
Public Property URLs As Generic.List(Of String)
Public Property CurrentlyWorkedURL As String

Public Property Reviews As Generic.List(Of Review)
Public Property ZIP As String
Public Property Categories As Generic.List(Of String)
Public Property Phone As String
Public Property Website As String
Public Property Email As String
Public Property Price As String
Public Property openingHour As String
Public Property Promotions As Generic.List(Of Promotion)
Public Property SomethingWrong As Boolean
Public Const ProfileFile As String = "profiles.txt"
Public Shared Splitter As Char() = " ,.'()#-/&;""".ToCharArray
Public Shared WordCount As Generic.Dictionary(Of String, Double)

Now, the District relationship.

Should I create an entity named District and then set up a one to many relationship between Restaurants and Districts?

However, District is just a string. It's kind of cumbersome to create another entities whose type is NSString. Also is it possible since NSString is not decended from NSManagedObject.

How to best implement attributes where one object can have many attributes.

Think about Employee classes with one name and multiple aliases. How would you implement that in core?



dejo
Apr 4, 2011, 11:09 PM
How would you implement that in core?
What is 'core'? Do you mean Core Data?

teguh123
Apr 5, 2011, 11:04 AM
What is 'core'? Do you mean Core Data?

Yes

balamw
Apr 5, 2011, 11:19 AM
I would suggest you read over the Collections Programming Topics document http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Collections/Collections.html

and a few links like:

http://stackoverflow.com/questions/793644/is-there-anything-like-a-generic-list-in-cocoa-objective-c

(google "generic list NSArray").

to map your .net structure over into an equivalent structure in Objective C.

B

admanimal
Apr 5, 2011, 01:53 PM
I would suggest you read over the Collections Programming Topics document http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Collections/Collections.html


If teguh123 had a dime for every time someone has told him to read that document, he could hire someone else to do this programming for him.

teguh123
Apr 7, 2011, 12:44 AM
If teguh123 had a dime for every time someone has told him to read that document, he could hire someone else to do this programming for him.

I read that and I think that's the wrong way to do it. I used coredata instead. I do not want to create all the classes from scratch.

Actually this one is solved. My next quest is how to download data from the web and then populate that CoreData somehow