0

This is my Swift class :

@objc public class UserParentMessage : NSObject {
   public var HasAttachments: Int?
   public var UserParentMessageId: Int?
   public var LatestReplyDateTime: String?
   public var LatestReplyDateTimeStr: String?
   public var NumberOfReplies: Int?
   public var ReadOn: String?
   public var SenderUserId: Int?
   public var Subject: String?
   public var TotalMessageCount: Int?
   public var sender: Sender?
}  

In Objective C class, I have created it's object as :

UserParentMessage *userParentMessage = [UserParentMessage new];  

I am able to access all String types (like LatestReplyDateTime, Subject) but not the other types. Probably doing some stupid mistake. What might that be ?

Nitish
  • 13,845
  • 28
  • 135
  • 263
  • what the isue u faced,.. – Anbu.Karthik Oct 05 '16 at 11:25
  • @Anbu.Karthik : I can access LatestReplyDateTime by userParentMessage. LatestReplyDateTime but when I do so for HasAttachments, it doesn't show up. Giving one of the examples. – Nitish Oct 05 '16 at 11:27
  • 1
    Consider not to use optionals as a *don't-care* alibi. `HasAttachments` is supposed to be a non-optional boolean and `NumberOfReplies` and `TotalMessageCount` are supposed to be non-optional, too. What is the practical purpose of a counter of *nil*? – vadian Oct 05 '16 at 11:30
  • @vadian : So instead should I use "public var HasAttachments: Int = 0" ? – Nitish Oct 05 '16 at 11:37
  • Yes, or `Bool = false` because actually it has only two states:has or has not attachments. – vadian Oct 05 '16 at 11:39
  • @vadian : Similar to c# then. – Nitish Oct 05 '16 at 11:39
  • I have no idea of c#. ;-) – vadian Oct 05 '16 at 11:43
  • I'm not sure since I never combined Swift and Objective-C in a single app, but maybe (just maybe) Objective-C isn't recognizing Sender and Int types. Try to use AnyObject and NSNumber instead. – VitorMM Oct 05 '16 at 11:47

0 Answers0