小编S.P*_*lip的帖子

nil,NULL和[NSNULL nil]之间有什么区别?

我得到了这样的错误 - *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:** - [NSCFDictionary initWithObjects:forKeys:count:]:尝试在对象[0]处插入nil值(键:搜索)'

然后我尝试了下面的代码

    if (Obj == (id)[NSNull null])  //Obj is an id 
{
    NSLog(@" Obj is (id)[NSNull null]");    
}
else if (Obj == nil)
{
    NSLog(@"Obj is nil");   
} 
else if (Obj == NULL)
{
    NSLog(@"Obj is NULL");  
} 
else
{
    NSLog(@"Obj is something else");
}

searchedDict = [NSDictionary dictionaryWithObject:Obj forKey:@"searched"];
Run Code Online (Sandbox Code Playgroud)

我得到的NSLog消息是'Obj is nil'.

但是当我使用相同的上述代码时Obj是NSString并且我的应用程序由于nil值而被终止,我得到了NSLog消息为'Obj is(id)[NSNull null]'.

nil,NULL和[NSNULL nil]之间有什么区别?

是否存在不同类型的Null值?如果是,如何检查这些空值

谢谢 :-)

iphone null objective-c invalidargumentexception

8
推荐指数
2
解决办法
2948
查看次数

JSON框架中重复的类有问题吗?

可能重复:
解决Objective-C命名空间冲突的最佳方法是什么?

在我的应用程序中,我使用SBJSON框架(Stig Brautaset)与我的json api进行交互,一切运行良好.

但现在我正在使用Facebook SDK使用Facebook SSO.所以我按照Facebook开发者网站的指示将facebook sdk包含在我的项目中.

但问题是,facebook sdk也使用了一些SBJSON类,如SBJSONParser,SBJsonWriter等,这些类已经存在于我使用过的SBJSON框架中.这些类的名称相似,但方法和属性不同.所以我既不能删除也不能编辑其中任何一个.(我是初学者,我不知道如何编辑它们而不会丢失任何东西).

因此,由于重复的类,它显示了许多错误.

我能在这做什么?请帮我 :)

下面给出了两个JSonParser类的头文件(.h).(.m文件不能在这里给出,因为它们太长了.)

在下面给出的Facebook SDK中使用的JSonParser.h

#import <Foundation/Foundation.h>
#import "SBJsonBase.h"

@protocol SBJsonParser
- (id)objectWithString:(NSString *)repr;

@end

@interface SBJsonParser : SBJsonBase <SBJsonParser> {

@private
const char *c;

}   
@end


@interface SBJsonParser (Private)

- (id)fragmentWithString:(id)repr;

@end
Run Code Online (Sandbox Code Playgroud)

在下面给出的SBJson Framework中使用的JSonParser.h

#import <Foundation/Foundation.h>

@interface SBJsonParser : NSObject {


NSString *error;
NSUInteger depth, maxDepth;

}

@property NSUInteger maxDepth;

@property(copy) NSString *error;

- (id)objectWithData:(NSData*)data;

- (id)objectWithData:(NSData*)data;

- (id)objectWithString:(NSString*)jsonText error:(NSError**)error;


@end
Run Code Online (Sandbox Code Playgroud)

谢谢 :)

iphone facebook objective-c duplicates sbjson

5
推荐指数
1
解决办法
1930
查看次数

如何删除sqlite中的最后10条记录

在Sqlite中,我可以知道如何删除最近10条记录吗?我写过以下编码,但似乎根本没有工作.

delete from tb_news where newsid = (SELECT newsid from tb_news order by newsid asc limit 10)
Run Code Online (Sandbox Code Playgroud)

sqlite

5
推荐指数
1
解决办法
4452
查看次数

添加另一个时如何删除以前的注释引脚?

我有一个UITableView,每个单元格都包含一个Map按钮.当我点击每个按钮时,会显示地图视图并添加相应的注释引脚.

点击每个地图按钮时会调用此代码,

    double tempLatitude  = [[[myDict objectForKey:key] objectAtIndex:15] doubleValue];
    double tempLongitude = [[[myDict objectForKey:key] objectAtIndex:16] doubleValue];
                                                  // key is the cell index.

         //--** Setting the Latitude and Longitude 
         CLLocationCoordinate2D myCoordinate;

         myCoordinate.latitude  = tempLatitude;
         myCoordinate.longitude = tempLongitude;

         MyMapAnnotation *MyAnnotation = [[[MyMapAnnotation alloc] initWithCoordinate:myCoordinate addressDictionary:nil]autorelease];
         MyAnnotation.title            = [[myDict objectForKey:key] objectAtIndex:1];
         MyAnnotation.subtitle         = [NSString  stringWithFormat:@"%f %f", MyAnnotation.coordinate.latitude, MyAnnotation.coordinate.longitude];
Run Code Online (Sandbox Code Playgroud)

这是MyMapAnnotation的代码,

    @synthesize coordinate = theCoordinate;
    @synthesize title = theTitleAnnotation;
    @synthesize subtitle = theSubTitleAnnotation;



    - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary 
    {

      if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
      { …
Run Code Online (Sandbox Code Playgroud)

iphone annotations objective-c mapkit mkmapview

3
推荐指数
1
解决办法
2550
查看次数

如果我们在应用名称中使用"iPhone"这个词,会有什么问题吗?

如果我们在应用名称中使用"iPhone"或"iPad"这个词,那会是拒绝我们应用的原因吗?

例如,名称如"我的iPhone风格"或"新iPad风格".

我很快就会提交一个应用程序而且很少有人对这个问题感到困惑.问题是,有必要在我的应用程序名称中使用iPhone这个词来确定我的应用程序的目的.请帮我.Thanx提前.:-)

iphone appstore-approval

2
推荐指数
1
解决办法
1257
查看次数