让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
2024-04-06 20:04

满意答案

我与帮助台聊天,他说你必须手动创建指向你的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)

https://www.namecheap.com/support/knowledgebase/article.aspx/319/78/how-can-i-setup-an-a-address-record-for-my-domain 这是一个很好的教程,可以帮助您完成旅程 https://www.namecheap.com/support/knowledgebase/article.aspx/319/78/how-can-i-setup-an-a-address-record-for-my-do...

EGit和GitHub的“验证失败”错误(“Auth Failed” error with EGit and GitHub)

我的答案可能已经过时了,但希望对某人有用。 在Eclipse中,转到“ 窗口”>“首选项”>“常规”>“网络连接”> “SSH2”(或仅在首选项窗口过滤框中键入“SSH2”)。 (DD)我试图加载一个已知的好的id_rsa密钥,我以前从命令行推我的存储库,并且工作正常。 当尝试在第二步中“添加”键时,我发现两个键的长度不同。 也许这是EGIT和eclipse正在发烧的地方? 我生成的github的密钥是2048,Eclipse / EGit生成的密钥长度是1024。不知道SSH是否足够好,看看是否...

github服务器验证失败(github server verification failed)

github今天早些时候遇到了一些问题,因为他们推出了government.github.com。 该网站现在应该正常运作。 github was experiencing some issues earlier today as they launched government.github.com. The site should be functioning normally now.

将Github链接到Namecheap:验证失败(Link Github to Namecheap: Validation failed)

我与帮助台聊天,他说你必须手动创建指向你的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://da...

Github和namecheap的域名主机记录(Domain host records for github and namecheap)

为了支持改进的Github页面,请像这样设置你的记录: HOST NAME IP ADDRESS RECORD TYPE TTL @ 192.30.252.153 A (Address) 1800 www <username>.github.io CNAME (Alias) 1800 然后,填写SUB-DOMAIN SETTINGS下的一行: HOST NAME IP ADDRESS...

使用github作为maven存储库校验和验证失败(using github as maven repository Checksum validation failed)

事实证明这很简单。 我只需要将存储库声明更改为引用raw.github.com ,如下所示: <repository> <id>com.github.cache4guice</id> <url>https://raw.github.com/dwatrous/cache4guice/mvn-repo</url> <!-- use snapshot version --> <snapshots> <enabled>true</enabled> ...

使用Namecheap电子邮件发送Nodemailer电子邮件(Send Nodemailer e-mail with Namecheap email)

在这种情况下,它可以是安全连接,端口应该是465 用于SSL的465端口,用于TLS / STARTTLS的25或26端口 It may be secured connection in that case the port should be 465 465 port for SSL, 25 or 26 for TLS/STARTTLS

Amazon EC2和Namecheap域和子域设置?(Amazon EC2 and Namecheap domain & subdomain setup?)

如果要使用子域,还需要在namecheap DNS中将该子域指向弹性IP,然后将apache中的子域绑定到它应该提供文件的网站/位置。 If you want to use a subdomain, you will also need to point that subdomain to the elastic ip as well in your namecheap DNS, and then bind the subdomain in apache to the website/locati...

DKIM hmailserver和NameCheap Setup(DKIM hmailserver and NameCheap Setup)

TXT条目的主机值应该是dkim._domainkey 。 目前您的域密钥位于: dkim._domainkey.linnabary.us.linnabary.us ,因此您不应在此处添加域名。 这就是为什么对测试电子邮件的响应说X-DKIM-Status: invalid (pubkey_unavailable) - 公共密钥无法找到它应该在的位置。 The Host value for your TXT entry should just be dkim._domainkey. Current...

Github失败了(Github failed push)

如果更改不是那么大,请考虑在项目之外的其他目录中复制整个文件夹/项目,然后git reset --hard HEAD将清除,删除和删除您最近的更改。 然后,您可以使用save3d副本再次单独应用它们以进行参考。 当然,确保在git commit之前确定git add 。 最后,如果您遇到自动提交合并问题,您可以随时手动编辑文件以解决问题。 If the changes aren't that big, consider making a copy of the entire folder/proj...

相关文章

更多

could not find system property or JNDI

Thanks everyone!! Finally got a solution for this p ...

mybatis There is no getter for property named 'xx' in 'class java.lang.String

用mybatis查询时,传入一个字符串传参数,且进行判断时,会报 There is no get ...

Java枚举学习笔记

为什么要有枚举 问题:要定义星期几或性别的变量,该怎么定义?假设用1-7分别表示星期一到星期日,但有人 ...

页面获取ACTION的属性,页面不能弹出JS

action定义一个属性,get set后 对属性赋值,值是JS,页面用&lt;s:property/ ...

solrcore.properties定义server是否是master

If the configuration directory for a Solr core cont ...

Guava Booleans类-布尔型基本的实用工具类

static int countTrue(boolean... values)返回为true值的数目

jsp中取绝对值 和百分比问题

&lt;s:iterator id=&quot;obInfoE&quot; value=&quot;o ...

【原】storm源码之巧用java反射反序列化clojure的defrecord获取属性值

storm源码是clojure、java、python的混合体。在解决storm-0.8.2的nimb ...

如何在jsf标签中使用java的枚举类型

在后台Java对象中有个枚举类型属性,例如学生的学科用枚举类型表示 class Student { ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本