ASNRealm 0.1.6

ASNRealm 0.1.6

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布时间最后发布时间2016年6月

Annisa Sofia 维护。



ASNRealm 0.1.6

  • 作者
  • Annisa Sofia Noviantina

示例

要运行示例项目,请先克隆仓库,并在 Example 目录中先运行 pod install

需求

安装

ASNRealm 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ASNRealm'
产品信息属性

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

示例日志
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;
    }

如何使用?

---如果您在使用它,请定义对象或结果--

导入 product 类
#import <ASNRealm/Product.h>
获取所有产品

属性排序是属性名

RLMResults *result =  [product getAllProductWithPropertyForSort:@"productId" withAscending:YES];
NSLog(@"result: %@",result);
从列表(image,stock,price,variant)访问属性和 RLMArray
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);
(搜索)通过标题或描述获取产品
Product *product = [[Product alloc]init];
RLMResults *result =  [product searchProductWithKeyword:@"Chunky Heels"];
NSLog(@"result: %@",result);
通过 productId 获取产品
Product *product = [[Product alloc]init];
RLMResults *result =  [product getProdutById:10];
NSLog(@"result: %@",result);
创建产品

首先定义图像、价格、库存和变体的数组

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"];

从产品类创建对象

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

使用默认的 wishlist(false)值创建产品

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

使用自定义的 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];
通过 productId 删除产品
Product *product = [[Product alloc]init];
[product deleteProductWithProductId:7];
获取所有 wishlist 为 true 的产品(显示所有收藏夹)
Product *product = [[Product alloc]init];
RLMResults *result =  [product getAllWishlistWithPropertyForSort:@"productId" withAscending:YES];
NSLog(@"result: %@",result);
通过productId添加商品到心愿单
Product *product = [[Product alloc]init];
[product addProductToWishlist:10];
通过productId从心愿单删除商品
Product *product = [[Product alloc]init];
[product removeProductFromWishlist:5];
清空心愿单
Product *product = [[Product alloc]init];
[product emptyWishlist];
清空商品
Product *product = [[Product alloc]init];
[product emptyProduct];
编辑商品

首先定义图像、价格、库存和变体的数组

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"];

从产品类创建对象

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

编辑产品

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

作者

Annisa Sofia Noviantina, [email protected]