osx - How to keep track of a class's objects in Objective C -
i'm new c , objective-c, , implement class method return nsdictionary of objects meeting criteria, such starred articles in example:
article.h:
@interface article : nsobject { nsstring *title; bool starred; } ... + (nsmutabledictionary*) starredarticles; @end
how approach this? static global nsmutablearray inside article.m file, insert/delete in constructor , destructor?
this isn't way go--there must object containing articles in application. that's object should return starred articles--this class method might seem idea now, it's inflexible.
so, have object storing articles in nsmutablearray
. use predicate (see the predicate programming guide) find starred articles , return desired dictionary.
Comments
Post a Comment