所以我收到了这个警告:
Semantic Issue: Incompatible pointer to integer conversion sending 'NSUInteger *' (aka 'unsigned int *') to parameter of type 'NSUInteger' (aka 'unsigned int')
Run Code Online (Sandbox Code Playgroud)
基本上我正在引入一个JSON提要..循环遍历它以匹配列与数据,然后将数据放在一个对象中用于表行...
NSDictionary *js_result = [response JSONValue];
NSLog(@"This is the LIST: %@",[js_result objectForKey:@"LIST"]);
// get columns
NSArray *columns = [[js_result objectForKey:@"LIST"] componentsSeparatedByString:@","];
// get data
NSArray *rows = [[js_result objectForKey:@"QUERY"] objectForKey:@"DATA"];
NSUInteger *study_id_int = (NSUInteger *)[columns indexOfObject:@"STUDY_ID_DICOM"];
NSUInteger *study_desc_int = (NSUInteger *)[columns indexOfObject:@"STUDY_DESCRIPTION"];
NSUInteger *study_date_int = (NSUInteger *)[columns indexOfObject:@"STUDY_DATETIME"];
NSUInteger *modality_int = (NSUInteger *)[columns indexOfObject:@"MODALITY"];
NSUInteger …Run Code Online (Sandbox Code Playgroud) 我为iphone/iPad开发应用程序.我想要对存储在NSArray中的对象进行洗牌.有没有办法用objective-c来实现它?
我有一个包含数组的plist,有许多项目我不按特定顺序维护.
当我从plist创建NSArray时,数组的对象是否与plist的顺序相同?例如.如果我执行如下代码,那么数组的项目是否与plist的顺序相同?
NSMutableDictionary* plistDictionary = [self someMethodToReadThePlistAsDictionary:plistName];
NSArray* array = [plistDictionary objectForKey:@"arrayKey"];
Run Code Online (Sandbox Code Playgroud)
有没有我可以验证的文件?在实践中似乎是这样,但我想以某种方式验证它.
编辑:我似乎正在为这个问题投票,所以让我澄清一下:我完全清楚数组维护插入顺序.我的问题与"plists"有关,因为我不知道当plist成为一个物体时会发生什么.
我有UISearchBar,UITableView,它返回一个Web服务NSMutableArray包含这样的对象:
//Food.h
Food : NSObject {
NSString *foodName;
int idFood;
}
@property (nonatomic, strong) NSString *foodName;
Run Code Online (Sandbox Code Playgroud)
而阵列:
Food *food1 = [Food alloc]initWithName:@"samsar" andId:@"1"];
Food *food2 = [Food alloc] initWithName:@"rusaramar" andId:@"2"];
NSSarray *array = [NSArray arrayWithObjects:food1, food2, nil];
Run Code Online (Sandbox Code Playgroud)
如何使用名称以"sa"开头的对象过滤我的数组?
我有以下包含NSDictionary的NSArray:
NSArray *data = [[NSArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1], @"bill", [NSNumber numberWithInt:2], @"joe", nil],
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:3], @"bill", [NSNumber numberWithInt:4], @"joe", [NSNumber numberWithInt:5], @"jenny", nil],
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:6], @"joe", [NSNumber numberWithInt:1], @"jenny", nil],
nil];
Run Code Online (Sandbox Code Playgroud)
我想创建一个过滤的NSArray,它只包含NSDictionary使用NSPredicate匹配多个"键"的对象.
例如:
任何人都可以解释NSPredicate的格式来实现这一目标吗?
编辑:我可以使用以下方法获得与所需NSPredicate类似的结果:
NSMutableArray *filteredSet = [[NSMutableArray alloc] initWithCapacity:[data count]];
NSString *keySearch1 = [NSString stringWithString:@"bill"];
NSString *keySearch2 = [NSString stringWithString:@"joe"];
for (NSDictionary *currentDict in data){
// objectForKey will return nil if a key doesn't exists.
if ([currentDict objectForKey:keySearch1] …Run Code Online (Sandbox Code Playgroud) 我有一个NSArray带NSDictionaries.其中一个数组中的一个字典键包含一个值.我想检索NSDictionary具有该值的.
我的阵列:
Array: (
{
DisplayName = "level";
InternalName = "Number 2";
NumberValue = 1;
},
{
DisplayName = "PurchaseAmount";
InternalName = "Number 1";
NumberValue = 3500;
}
)
Run Code Online (Sandbox Code Playgroud)
所以,我想得到包含DisplayNameset 的字典PurchaseAmount(不区分大小写).
我怎么能做到这一点?
所以我在工作中遇到了一个大问题,因为我的代码中有类似的东西:
int foo = -1;
NSArray *bar = [[NSArray alloc] initWithObjects:@"1",@"2",@"3", nil];
if (foo > [bar count]){
NSLog(@"Wow, that's messed up.");
} else {
NSLog(@"Rock on!");
}
Run Code Online (Sandbox Code Playgroud)
你可能已经知道我发布这个,输出是:
"哇,这搞砸了."
从我收集的内容来看,目标C将我的负数转换为"已签名"的int,从而杀死了我的比较.
我看到了关于这个的其他帖子,他们都说明了问题所在,但他们都没有建议任何简单的解决方案来实现这种比较.此外,我很震惊,没有编译器警告,因为这些对我来说是严重的问题.
我有一组存储在数组中的字符串.
stringArray = [Aruna, Bala, Chitra, Divya, Fatima]
Run Code Online (Sandbox Code Playgroud)
我想得到所有字符串的第一个字母并将其存储在一个数组中.喜欢:letterArray = [A, B, C, D, F]
注意:它们不在引号" - "内
我收到了一些回复JSON,并且工作正常,但我需要检查一些null值,
我找到了不同的答案,但似乎还没有工作,
NSArray *productIdList = [packItemDictionary objectForKey:@"ProductIdList"];
Run Code Online (Sandbox Code Playgroud)
我试过了
if ( !productIdList.count ) //which breaks the app,
if ( productIdList == [NSNull null] ) // warning: comparison of distinct pointer types (NSArray and NSNull)
Run Code Online (Sandbox Code Playgroud)
那么发生了什么?如何修复此问题并null在我的阵列中检查?
谢谢!
在iOS中,我想为NSArray实现map函数.这是一个应用于数组的每个元素的函数.实现这个的最佳方法是什么?
谢谢,
道格
nsarray ×10
objective-c ×7
ios ×6
ipad ×2
iphone ×2
cocoa ×1
ios4 ×1
mapreduce ×1
nsdictionary ×1
nspredicate ×1
null ×1
plist ×1
swift ×1