下标要求接口'NSArray'的大小,在不稳定的ABI中,该大小不是恒定的 [英] Subscript requires size of interface 'NSArray', which is not constant in non-stable ABI

查看:69
本文介绍了下标要求接口'NSArray'的大小,在不稳定的ABI中,该大小不是恒定的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ASIHTTPRequest将信息发送到服务器,并设置如下的发布值:

I'm trying to send information to a server using ASIHTTPRequest and am setting the post values like this:

    for(int i = 0;i<13;i++){
  [request setPostValue:propertyValues[i] forKey:propertyKeys[i]]    
}

propertyValues和propertyKeys都是NSArray对象,每个对象都包含13个项目.运行此命令时,出现错误下标需要接口'NSArray'的大小,在不稳定的ABI中不是恒定的"

propertyValues and propertyKeys are both NSArray objects that hold 13 items each. When I run this, I get the error "Subscript requires size of interface 'NSArray', which is not constant in non-stable ABI"

这是什么意思?

推荐答案

这意味着您正在尝试访问NSArray*,就好像它是一个数组或可以进行算术操作的指针一样.指针类型的x[5]等效于x + sizeof(x) * 5.注意sizeof运算符-这意味着编译器需要知道类型的大小才能使指针前进5个项".但是,NSArray是Objective C接口,编译器无法确定类型的大小.这解释了您得到的错误的措辞.

It means you're trying to access an NSArray* as if it were an array, or a pointer you could do arithmetic with. x[5] for pointer types is equivalent to x + sizeof(x) * 5. Note the sizeof operator - it means the compiler needs to know the size of the type to advance the pointer by 5 "items". However, NSArray is an Objective C interface, and the compiler can't be sure what the size of the type is. This explains the wording of the error you're getting.

更一般地说,您无法访问这样的NSArray对象.您需要向他们发送一条消息,要求在给定的索引下搜索商品,因此:

More prosaically, you can't access NSArray objects like that. You need to send them a message asking for the item at a given index, thus:

[propertyValues objectAtIndex:i];

这篇关于下标要求接口'NSArray'的大小,在不稳定的ABI中,该大小不是恒定的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆