Latest 0.1.6
Homepage https://github.com/sovianisa/ASNRealm
License MIT
Platforms ios 8.0
Dependencies Realm
Frameworks UIKit
Authors

[![CI Status](http://img.shields.io/travis/Annisa Sofia Noviantina/ASNRealm.svg?style=flat)](https://travis-ci.org/Annisa Sofia Noviantina/ASNRealm)
Version
Platform

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];
Product *singleProduct =  [product getProdutById:10];

    if (singleProduct == nil) {
        NSLog(@"product not found");
    } else {
        NSLog(@"title:%@",singleProduct.title);
        NSLog(@"description:%@",singleProduct.descriptions);
        NSArray *getImages = [product getImagesByProductObject:singleProduct];
        NSArray *getStocks= [product getStockByProductObject:singleProduct];
        NSArray *getPrices= [product getPriceByProductObject:singleProduct];
        NSArray *getVariant= [product getVariantByProductObject:singleProduct];
        NSLog(@"images : %@",getImages);
        NSLog(@"stocks : %@",getStocks);
        NSLog(@"price : %@",getPrices);
        NSLog(@"variant : %@",getVariant);

}
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]

Latest podspec

{
    "name": "ASNRealm",
    "version": "0.1.6",
    "summary": "help using realm for sophify",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/sovianisa/ASNRealm",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Annisa Sofia Noviantina": "[email protected]"
    },
    "source": {
        "git": "https://github.com/sovianisa/ASNRealm.git",
        "tag": "0.1.6"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "ASNRealm/Classes/**/*",
    "frameworks": "UIKit",
    "dependencies": {
        "Realm": []
    }
}

Pin It on Pinterest

Share This