我是xcode的新手,正在嘗試使用我沒有編寫的代碼。非常抱歉,如果這是一個愚蠢的問題!在.h文件中聲明的實體的訪問屬性
運行我的代碼後,我在這裏創建實體(實體由Entities.h定義):
Entities *proxy = [[Entities alloc]initWithUri:@"http://localhost:8080/Resource/example.svc" credential:nil];
DataServiceQuery *qry = [proxy person];
QueryOperationResponse *result = [qry execute];
items = [result getResult];
NSLog(@"items size: %@", items);
這個偉大的工程,並打印如下:
然而,我沒有IDEA如何訪問Model_person中的變量。
從Entities.h相關的代碼是:
/**
* @interface:person
* @Type:EntityType
* @key:person_id*
*/
@interface Model_person : ODataObject
{
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_id;
/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_role;
/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_firstname;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_department;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_contractor;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_supervisor;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_admin;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_workweek;
/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_employee_id;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_billrate;
/**
* @Type:EntityProperty
* @EdmType:Edm.String
* @MaxLength:255
* @FixedLength:
*/
NSString *m_person_lastname;
/**
* @Type:EntityProperty
* @EdmType:Edm.Int32
*/
NSNumber *m_person_active;
}
@property (nonatomic , retain , getter=getperson_id , setter=setperson_id :)NSNumber *m_person_id;
@property (nonatomic , retain , getter=getperson_role , setter=setperson_role :) NSString *m_person_role;
@property (nonatomic , retain , getter=getperson_firstname , setter=setperson_firstname :) NSString *m_person_firstname;
@property (nonatomic , retain , getter=getperson_department , setter=setperson_department :)NSNumber *m_person_department;
@property (nonatomic , retain , getter=getperson_contractor , setter=setperson_contractor :)NSNumber *m_person_contractor;
@property (nonatomic , retain , getter=getperson_supervisor , setter=setperson_supervisor :)NSNumber *m_person_supervisor;
@property (nonatomic , retain , getter=getperson_admin , setter=setperson_admin :)NSNumber *m_person_admin;
@property (nonatomic , retain , getter=getperson_workweek , setter=setperson_workweek :)NSNumber *m_person_workweek;
@property (nonatomic , retain , getter=getperson_employee_id , setter=setperson_employee_id :) NSString *m_person_employee_id;
@property (nonatomic , retain , getter=getperson_billrate , setter=setperson_billrate :)NSNumber *m_person_billrate;
@property (nonatomic , retain , getter=getperson_lastname , setter=setperson_lastname :) NSString *m_person_lastname;
@property (nonatomic , retain , getter=getperson_active , setter=setperson_active :)NSNumber *m_person_active;
+ (id) Createperson;
- (id) init;
- (id) initWithUri:(NSString*)anUri;
@end
注: 我試圖訪問元素的cellForRowAtIndexPath後續的方式:
Entities *event = [items objectAtIndex:indexPath.row];
cell.textLabel.text = [[[event getperson] objectAtIndex: 0] getName];
丟給一個錯誤說「不'DataServiceQuery'的可見@interface聲明選擇器'ObjectAtIndex'「
UPDATE:
getperson也被定義在Entities.h:
/**
* Container interface Entities, Namespace: Model
*/
@interface Entities : ObjectContext
{
NSString *m_OData_etag;
DataServiceQuery *m_member;
DataServiceQuery *m_cumulative;
DataServiceQuery *m_date;
DataServiceQuery *m_holiday;
DataServiceQuery *m_associations;
DataServiceQuery *m_department;
DataServiceQuery *m_person;
DataServiceQuery *m_project;
}
@property (nonatomic , retain , getter=getEtag , setter=setEtag :)NSString *m_OData_etag;
@property (nonatomic , retain , getter=getmember , setter=setmember :) DataServiceQuery *m_member;
@property (nonatomic , retain , getter=getcumulative , setter=setcumulative :) DataServiceQuery *m_cumulative;
@property (nonatomic , retain , getter=getdate , setter=setdate :) DataServiceQuery *m_date;
@property (nonatomic , retain , getter=getholiday , setter=setholiday :) DataServiceQuery *m_holiday;
@property (nonatomic , retain , getter=getassociations , setter=setassociations :) DataServiceQuery *m_associations;
@property (nonatomic , retain , getter=getdepartment , setter=setdepartment :) DataServiceQuery *m_department;
@property (nonatomic , retain , getter=getperson , setter=setperson :) DataServiceQuery *m_person;
@property (nonatomic , retain , getter=getproject , setter=setproject :) DataServiceQuery *m_project;
- (id) init;
- (id) initWithUri:(NSString*)anUri credential:(id)acredential;
- (id) member;
- (id) cumulative;
- (id) date;
- (id) holiday;
- (id) associations;
- (id) department;
- (id) person;
- (id) project;
- (void) addTomember:(id)anObject;
- (void) addTocumulative:(id)anObject;
- (void) addTodate:(id)anObject;
- (void) addToholiday:(id)anObject;
- (void) addToassociations:(id)anObject;
- (void) addTodepartment:(id)anObject;
- (void) addToperson:(id)anObject;
- (void) addToproject:(id)anObject;
@end
所以'items'不似乎是一個陣列。這兩個代碼在哪裏? – Wain
項目是NSMutableArray。什麼是「2段代碼」? – AllieCat
好的,那麼定義getperson是什麼,它返回什麼? – Wain