{"id":3864,"date":"2014-03-30T06:07:29","date_gmt":"2014-03-30T06:07:29","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-create-generic-id-type-properties-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:07:29","modified_gmt":"2014-03-30T06:07:29","slug":"how-to-create-generic-id-type-properties-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-create-generic-id-type-properties-collection-of-common-programming-errors\/","title":{"rendered":"How to create generic id type properties?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m new to iOS and Objective-C and trying to create a class that has a generic property.<\/p>\n<p><code>@interface HeaderInfo : NSObject { NSString *label; id value; }<\/code><\/p>\n<pre><code><code>@property (nonatomic, retain) NSString *label;\n@property (nonatomic, retain) id value;\n- (HeaderInfo *)initWithLabel:(NSString *)lbl value:(id)val;\n\n@end\n<\/code><\/code><\/pre>\n<p>Then I&#8217;m trying to add this class to an array:<\/p>\n<p><code>[generalSection.items addObject:[[HeaderInfo alloc] initWithLabel:@\"Tacho seal security\" value:@\"Some String Value\"]];<\/code><\/p>\n<p><code>[generalSection.items addObject:[[HeaderInfo alloc] initWithLabel:@\"Tacho seal security\" value:YES]];<\/code><\/p>\n<p>but compiler doesn&#8217;t like the 2nd addition and says:<\/p>\n<p><code>Warning: passing argument 2 of 'initWithLabel:value:' makes pointer from integer without a cast<\/code><\/p>\n<p>What I&#8217;m doing wrong? Any help is greatly appreciated.<\/p>\n<p>And also how can check the value later on whether it&#8217;s a BOOL or NSString?<\/p>\n<p>Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m new to iOS and Objective-C and trying to create a class that has a generic property. @interface HeaderInfo : NSObject { NSString *label; id value; } @property (nonatomic, retain) NSString *label; @property (nonatomic, retain) id value; &#8211; (HeaderInfo *)initWithLabel:(NSString *)lbl value:(id)val; @end Then I&#8217;m trying to add this class to an array: [generalSection.items addObject:[[HeaderInfo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3864","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3864"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3864\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}