I'm using AFNetworking to add Book objects to a server. Here's the setup:
Some dummy Book
objects are created for testing:
Book *newBook1 = [[Book alloc] init];
newBook1.title = @"Test Book 1";
newBook1.author = @"Harlan";
Book *newBook2 = [[Book alloc] init];
newBook2.title = @"Test Book 2";
newBook2.author = @"Harlan";
NSArray *books = [NSArray arrayWithObjects:newBook1, newBook2, nil];
[bookCommunicator addBooks:books];
Inside BookCommunicator
:
- (void)addBooks:(NSArray *)books
{
for(Book *book in books)
{
[self addBook:book];
}
}
- (void)addBook:(Book *)book
{
NSDictionary *bookProperties = [NSDictionary dictionaryWithObjectsAndKeys:
book.author, @"author",
book.title, @"title",
nil];
[_httpSessionManager POST:@"books" parameters:bookProperties
success:^(NSURLSessionDataTask *task, id responseObject) {
[self.delegate didAddBooks];
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
[self.delegate addingBooksFailedWithError:error];
}
];
}
I get a success response. The responseObject
is an array of all of the Book
objects already on the server - excluding the new ones. Upon checking the server, these two new book objects are not there. Any ideas as to why?