zoukankan      html  css  js  c++  java
  • FMDB使用注意事项

    1、数据格式必须是NSObject对象,即使在数据表中是整型(integer)、浮点型(float),如

        NSString * dishId = [_infoDictionary objectForKey:@"id"];
        NSString * dishName = [_infoDictionary objectForKey:@"name"];
        NSString * specialPrice = [NSString stringWithFormat:@"%@",[_infoDictionary objectForKey:@"favorablePrice"]];
        NSString * price = [NSString stringWithFormat:@"%@",[_infoDictionary objectForKey:@"price"]];
        NSString * countStr = @"1";
        BOOL insert = [database executeUpdate:@"insert into menu values (?,?,?,?,?)",dishId,dishName,specialPrice,price,countStr];

    上面是正确的代码,如果使用如下格式插入数据,则会bad access..

        NSString * dishId = [_infoDictionary objectForKey:@"id"];
        NSString * dishName = [_infoDictionary objectForKey:@"name"];
        NSString * specialPrice = [_infoDictionary objectForKey:@"favorablePrice"];
        NSString * price = [_infoDictionary objectForKey:@"price"];
        NSString * countStr = @"1";
        BOOL insert = [database executeUpdate:@"insert into menu values (?,?,?,?,?)",dishId,dishName,specialPrice,price,countStr];

    注意,

    [_infoDictionary objectForKey:@"price"]与
    [_infoDictionary objectForKey:@"favorablePrice"]
    是浮点型字符串,如@"12.5"
  • 相关阅读:
    springIOC 原理
    jeesite异步分页
    yum
    乐观锁原理
    equlas(),hashcode(),hashset,hashmap
    链接收藏
    java单词
    jeesite优化
    SailingEase .NET Resources Tool (.NET 多语言资源编辑器)转
    C#基本语法
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3091149.html
Copyright © 2011-2022 走看看