In Objective-C you will be better off working with NSDictionaries or custom objects rather than structs. Expanding on H2CO3's comments - you could declare a BookCollection class
BookCollection.h
#import <Foundation/Foundation.h>
@interface BookCollection: NSObject
@property (nonatomic, strong) NSString* title
@property (nonatomic, strong) NSArray* books
//use NSArray* for a static array or NSMutableArray* for a dynamic array
@end
BookCollection.m
#import "BookCollection/BookCollection.h"
@implementation BookCollection
@end
Your implementation is empty as you object only has public properties and no custom methods. We use @property syntax to declare our instance variables as this brings many advantages such as built-in getters and setters. (See my answer here for details)
Unlike C++ you can mix object types inside collection classes, so your books array won't complain if you add titles, books and other book collections: your code should ensure consistency. We do not declare array size. For a static NSArray the size is implied on creation, for a dynamic NSMutableArray there is no fixed limit. For a collection of fifty book collections, create an NSArray of fifty pre-existing collections. Alternatively create an NSMutableArray which you can add to incrementally.
BookCollection* joyce = [[BookCollection alloc] init];
joyce.title = @"Books by James Joyce";
joyce.books = @["Ulysses",@"Finnegan's Wake"]; //using static NSArray
BookCollection* tolkien = [[BookCollection alloc] init];
tolkien.title = @"Books by J.R.R. Tolkien";
[tolkien.books addObject:@"The Hobbit"]; //using dynamic NSMutableArray
[tolkien.books addObject:@"Lord of the Rings"];
For a dynamic array of collections:
NSMutableArray* collections = [[NSMutableArray alloc] init];
[collections addObject:joyce];
[collections addObject:tolkien];
For a fixed array you can use literal syntax:
NSArray* collections = @[joyce, tolkien];
For numberOfBooks, just use the count
property of arrays
int numberOfBooks = joyce.books.count;
If you want to ensure that collections are created with titles and books, use a custom initialiser, as per adrusi's answer. This is not required to make the object work, but it is useful if you want to guarantee that your objects have content.
To access instance variables, use [message syntax]
(the original obj-C way) or dot.syntax
(which works with @properties)
[tolkien books]
joyce.books
Don't use ->
arrow syntax. See here for a detailed explanation.