NSInternalInconsistencyException variable is not a property of projectName Classname

0 votes

I'm trying to work with a DynamoDB table, and have successfully connected to it, but am unable to read it. When I try, I get the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '_datePublished is not a property of ProjectName.Article.'

Here's my Article class/model:

class Article: AWSDynamoDBObjectModel, AWSDynamoDBModeling {

  var _articleSource: String?
  var _articleUrl: String?
  var _datePublished: String?
  var _headline: String?
  var _imageURL: String?
  var _rating: String?
  var _listingId: String?

  class func dynamoDBTableName() -> String {
    return "tableName"
  }

  class func hashKeyAttribute() -> String {
    return "_listingId"
  }

  class func rangeKeyAttribute() -> String {
    return "_articleUrl"
  }

  override class func jsonKeyPathsByPropertyKey() -> [AnyHashable: Any] {
    return [
      "_articleSource" : "articleSource",
      "_articleUrl" : "articleUrl",
      "_datePublished" : "datePublished",
      "_headline" : "headline",
      "_imageURL" : "imageURL",
      "_rating" : "rating",
      "_listingId" : "listingId",
    ]
  }
}

And the function I'm calling in ViewDidLoad to read an article from the DB:

 func readArticle() {
let dynamoDbObjectMapper = AWSDynamoDBObjectMapper.default()

// Create data object
let article: Article = Article();
dynamoDbObjectMapper.load(
  Article.self,
  hashKey: "2018-03-17T08:50:30+00:00",
  rangeKey: "https://www.example.com",
  completionHandler: {
    (objectModel: AWSDynamoDBObjectModel?, error: Error?) -> Void in
    if let error = error {
      print("Amazon DynamoDB Read Error: \(error)")
      return
    }
    print("Article:\n \(article)")
})

}

What am I doing wrong? datePublished exists in that entry on the DB, and is defined in the model

Sep 7, 2018 in AWS by bug_seeker
• 15,510 points
874 views

1 answer to this question.

0 votes

It turns out the AWS SDK isn't exactly Swift 4 compatible yet. In swift 4, you have to put @objcMembers before the object model class definition like:

    @objcMembers class Article: AWSDynamoDBObjectModel, AWSDynamoDBModeling { 

}
answered Sep 7, 2018 by Priyaj
• 58,020 points

Related Questions In AWS

0 votes
1 answer

if instance is a part of some AutoScaling Group in AWS or not ?

You can run this command below on ...READ MORE

answered Jun 2, 2018 in AWS by Cloud gunner
• 4,670 points
1,789 views
0 votes
1 answer

What is the maximum storage capacity of a node in Redshift?

You can create a cluster using either ...READ MORE

answered Oct 26, 2018 in AWS by Archana
• 5,640 points
2,099 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

In Amazon Data Pipeline, how to make sure only once instance of a pipeline is running at any time?

On the CopyTablesActivity, you could set a lateAfterTimeout attribute ...READ MORE

answered Sep 19, 2018 in AWS by Priyaj
• 58,020 points
2,164 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP