ASNRealm 0.1.6

ASNRealm 0.1.6

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2016

Maintained by Annisa Sofia.



ASNRealm 0.1.6

  • By
  • Annisa Sofia Noviantina

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

ASNRealm is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ASNRealm'
Attributte Product information

@property int productId; @property NSString *title; @property NSString *descriptions; @property RLMArray *images; @property RLMArray *prices; @property RLMArray *stocks; @property RLMArray *variants; @property BOOL wishlist;

Example Log
RLMResults <0x7f94b8f6f990> (
    [0] Product {
        productId = 7;
        title = title2;
        descriptions = desc2;
        images = RLMArray <0x7f94b8f74c90> (
            [0] Image {
                image = http://proprofs-cdn.s3.amazonaws.com/images/games/user_images/misc/1141652403.png;
                productIdImage = 7;
            },
            [1] Image {
                image = https://pixabay.com/static/uploads/photo/2013/08/11/19/37/flower-171644_960_720.jpg;
                productIdImage = 7;
            }
        );
        prices = RLMArray <0x7f94b8f75ed0> (
            [0] Price {
                price = 140;
                productIdPrice = 7;
            },
            [1] Price {
                price = 150;
                productIdPrice = 7;
            }
        );
        stocks = RLMArray <0x7f94b8f76970> (
            [0] Stock {
                stock = 15;
                productIdStock = 7;
            },
            [1] Stock {
                stock = 25;
                productIdStock = 7;
            }
        );
        variants = RLMArray <0x7f94b8f75c90> (
            [0] Variant {
                variant = red;
                productIdVariant = 7;
            },
            [1] Variant {
                variant = black;
                productIdVariant = 7;
            }
        );
        wishlist = 0;
    }

how to use it?

---please define object or result if you using it--

To import class product :
#import <ASNRealm/Product.h>
Get All Products :

Property sort is attribute name

RLMResults *result =  [product getAllProductWithPropertyForSort:@"productId" withAscending:YES];
NSLog(@"result: %@",result);
Access attribute and RLMArray from list (image,stock,price,variant) :
Product *product = [[Product alloc]init];
RLMResults *result =  [product getAllProductWithPropertyForSort:@"productId" withAscending:YES];
NSLog(@"result %lu: %@",(unsigned long)result.count,result);
Product *productAtIndex = [result objectAtIndex:1];
NSLog(@"title : %@:",productAtIndex.title);
NSLog(@"descriptions : %@:",productAtIndex.descriptions);
NSArray *getImages = [product getImagesByProductObject:productAtIndex];
NSArray *getStocks= [product getStockByProductObject:productAtIndex];
NSArray *getPrices= [product getPriceByProductObject:productAtIndex];
NSArray *getVariant= [product getVariantByProductObject:productAtIndex];
NSLog(@"images : %@",getImages);
NSLog(@"stocks : %@",getStocks);
NSLog(@"price : %@",getPrices);
NSLog(@"variant : %@",getVariant);
(Search) Get Products by Title or Description :
Product *product = [[Product alloc]init];
RLMResults *result =  [product searchProductWithKeyword:@"Chunky Heels"];
NSLog(@"result: %@",result);
Get product by productId :
Product *product = [[Product alloc]init];
RLMResults *result =  [product getProdutById:10];
NSLog(@"result: %@",result);
Create Product :

Define Array of images, prices, stocks and variants first

NSArray *images = @[@"http://proprofs-cdn.s3.amazonaws.com/images/games/user_images/misc/1141652403.png", @"https://pixabay.com/static/uploads/photo/2013/08/11/19/37/flower-171644_960_720.jpg"];
NSArray *prices = @[@140.0, @150.0];
NSArray *stocks = @[@"15", @"25"];
NSArray *variants = @[@"red", @"black", @"blue"];

Create object from class of product

Product *product = [[Product alloc]init];

Create product with default value of wishlist (false)

[product createDefaultProductWithId:7 withTitle:@"Croco Bag" andDescriptions:@"Nice handbag for women" andImages:images andPrices:prices andStocks:stocks andVariants:variants];

Create product with custom value of wishlist (false/true) YES : true, NO : false

[product createProductWithId:10 withTitle:@"Chelsea Chunky Heels Boot" andDescriptions:@"Stylist boot for this winter" andImages:images andPrices:prices andStocks:stocks andVariants:variants andWishlist:YES];
Delete Product by productId :
Product *product = [[Product alloc]init];
[product deleteProductWithProductId:7];
Get all Products where wishlist is true (Show all wishlist) :
Product *product = [[Product alloc]init];
RLMResults *result =  [product getAllWishlistWithPropertyForSort:@"productId" withAscending:YES];
NSLog(@"result: %@",result);
Add Product to Wishlist by productId :
Product *product = [[Product alloc]init];
[product addProductToWishlist:10];
Remove Product from Wishlist by productId :
Product *product = [[Product alloc]init];
[product removeProductFromWishlist:5];
Empty Wishlist :
Product *product = [[Product alloc]init];
[product emptyWishlist];
Empty Product :
Product *product = [[Product alloc]init];
[product emptyProduct];
Edit Product:

Define Array of images, prices, stocks and variants first

NSArray *images = @[@"http://proprofs-cdn.s3.amazonaws.com/images/games/user_images/misc/1141652403.png", @"https://pixabay.com/static/uploads/photo/2013/08/11/19/37/flower-171644_960_720.jpg"];
NSArray *prices = @[@80.0, @50.0, @70];
NSArray *stocks = @[@"10", @"5"];
NSArray *variants = @[@"red", @"black", @"blue"];

Create object from class of product

Product *product = [[Product alloc]init];

Edit product

[product editProductWithId:7 withTitle:@"Croco Bag Sale!" andDescriptions:@"Now favorite item on SALE" andImages:images andPrices:prices andStocks:stocks andVariants:variants andWishlist:YES];

Author

Annisa Sofia Noviantina, [email protected]