                     if let image = NSURL(string: imageURL), document = NSURL(string: docURL) {
                         let book = Book(title: title, authors: authors, tags: tags, image: image, document: document)
 
+                        if let favoritesArray = favoritesArray where favoritesArray.contains(book.proxyForComparasion) {
+                            book.isFavorite = true
+                            dictionary[favoritesTag]?.append(book)
+                        }
+                        
+                        book.delegate = self
+                        
                         for each in tags {
                             if self.tags.indexOf(each) == nil {
                                 self.tags.append(each)


import Foundation

class Library {
    typealias BooksArray = [Book]
    
    var tags = [String]()
    var dictionary = [String: BooksArray]()
    
    init (json: NSData) {
        if let jsonArray = try? JSONManager.loadFromData(json) {
            
            for dict:JSONDictionary in jsonArray {
                if let title = dict["title"] as? String,

            }
            
            sort()
            
            tags.insert(favoritesTag, atIndex: 0)
        }
    }
    
