让NSMutableArray属性填充枚举值(getting NSMutableArray Property filled with enumerated values)
尝试通过使用枚举值填充的NSMutableArray属性中的索引获取枚举值。
我想要的只是设置一个动态属性并在类实例中进行设置。
因此,我编写了一个揭示问题的明确例子。
问题是这个。 示例中的WriteByType方法永远不会获得正确的值。 它应该记录“你得到右箭头”,但事实并非如此
//---------------------------------------------------------- // CCMyClass.h #import <Foundation/Foundation.h> typedef enum { aLeft, aRight } Arrow; @interface CCMyClass : NSObject { NSMutableArray *_arrowsPkg; } @property(nonatomic,copy) NSMutableArray *arrowsPkg; @property (nonatomic)int nextPkgIndex; -(void)GetItemOne; @end //------------------------------------------------------------- // CCMyClass.m #import "CCMyClass.h" @implementation CCMyClass @synthesize arrowsPkg=_arrowsPkg; -(void)WriteByType:(Arrow)AArrow { switch (AArrow) { case aLeft: NSLog(@"You Get Left Arrow"); break; case aRight: NSLog(@"You Get Right Arrow"); break; } } -(void)GetItemOne { Arrow a =(Arrow)[[self arrowsPkg]objectAtIndex:1]; [self WriteByType:a]; } @end //---------------USAGE EXAMPLE---------------------------------------------- // CCAppDelegate.m - (IBAction)btn1Clicked:(id)sender { CCMyClass *c1=[[CCMyClass alloc]init]; NSNumber *v1=[NSNumber numberWithInt:aLeft]; NSNumber *v2=[NSNumber numberWithInt:aRight]; NSMutableArray *arr1=[NSMutableArray arrayWithObjects:v1,v2, nil]; [c1 setArrowsPkg:arr1]; [c1 GetItemOne]; }
Attempting to get an enumerated value by an index from a NSMutableArray property that is filled with enumerated values.
all I wanted is to set a dynamic property and get set back within class instance.
thus, I coded a clear example that expose of problem.
Problem is this. WriteByType method in example never gets correct value. it should log "You Get Right Arrow" but it doesn't
//---------------------------------------------------------- // CCMyClass.h #import <Foundation/Foundation.h> typedef enum { aLeft, aRight } Arrow; @interface CCMyClass : NSObject { NSMutableArray *_arrowsPkg; } @property(nonatomic,copy) NSMutableArray *arrowsPkg; @property (nonatomic)int nextPkgIndex; -(void)GetItemOne; @end //------------------------------------------------------------- // CCMyClass.m #import "CCMyClass.h" @implementation CCMyClass @synthesize arrowsPkg=_arrowsPkg; -(void)WriteByType:(Arrow)AArrow { switch (AArrow) { case aLeft: NSLog(@"You Get Left Arrow"); break; case aRight: NSLog(@"You Get Right Arrow"); break; } } -(void)GetItemOne { Arrow a =(Arrow)[[self arrowsPkg]objectAtIndex:1]; [self WriteByType:a]; } @end //---------------USAGE EXAMPLE---------------------------------------------- // CCAppDelegate.m - (IBAction)btn1Clicked:(id)sender { CCMyClass *c1=[[CCMyClass alloc]init]; NSNumber *v1=[NSNumber numberWithInt:aLeft]; NSNumber *v2=[NSNumber numberWithInt:aRight]; NSMutableArray *arr1=[NSMutableArray arrayWithObjects:v1,v2, nil]; [c1 setArrowsPkg:arr1]; [c1 GetItemOne]; }
原文:https://stackoverflow.com/questions/14667493
满意答案
我与帮助台聊天,他说你必须手动创建指向你的github帐户的cname记录。
http://davidensinger.com/2013/03/setting-the-dns-for-github-pages-on-namecheap/
I chatted with the helpdesk and he said that you have to create the cname record pointing to your github account manually.
http://davidensinger.com/2013/03/setting-the-dns-for-github-pages-on-namecheap/
相关问答
更多通过namecheap设置URL(Setting up URL through namecheap)
EGit和GitHub的“验证失败”错误(“Auth Failed” error with EGit and GitHub)
github服务器验证失败(github server verification failed)
将Github链接到Namecheap:验证失败(Link Github to Namecheap: Validation failed)
Github和namecheap的域名主机记录(Domain host records for github and namecheap)
使用github作为maven存储库校验和验证失败(using github as maven repository Checksum validation failed)
使用Namecheap电子邮件发送Nodemailer电子邮件(Send Nodemailer e-mail with Namecheap email)
Amazon EC2和Namecheap域和子域设置?(Amazon EC2 and Namecheap domain & subdomain setup?)
DKIM hmailserver和NameCheap Setup(DKIM hmailserver and NameCheap Setup)
Github失败了(Github failed push)
相关文章
更多could not find system property or JNDI
mybatis There is no getter for property named 'xx' in 'class java.lang.String
Java枚举学习笔记
INSERT INTO blog_appitem (user_id,appid,app_secret,is_valid) VALUES (1, 'wxf415741de036114c','48e1e345fd5f11c93af18ff1714c7f78',1)
页面获取ACTION的属性,页面不能弹出JS
solrcore.properties定义server是否是master
Guava Booleans类-布尔型基本的实用工具类
jsp中取绝对值 和百分比问题
【原】storm源码之巧用java反射反序列化clojure的defrecord获取属性值
如何在jsf标签中使用java的枚举类型
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!