Questions tagged [class-cluster]

A class cluster is an architecture that groups a number of private, concrete subclasses under a public, abstract superclass. The grouping of classes in this way provides a simplified interface to the user, who sees only the publicly visible architecture.

A class cluster is an architecture that groups a number of private, concrete subclasses under a public, abstract superclass. The grouping of classes in this way provides a simplified interface to the user, who sees only the publicly visible architecture.

Source: Cocoa Core Competencies (Class Cluster)

24 questions
1
vote
1 answer

Objective-c - Recommended pattern to cascade decision making in a class cluster

I would like to create a "multi-level" class cluster such that each "concrete" class could return a more specific instance when certain criteria are met. For instance in the base class: @interface BaseClass : NSObject // this is the public API of…
Avba
  • 14,822
  • 20
  • 92
  • 192
1
vote
1 answer

Class cluster with ARC

I'm trying to create a class cluster as subclass of UIViewController to accomplish some points: 1. Different behavior of the ViewController depending on actual iOS version 2. iOS version checks don't clutter up the code 3. Caller doesn't need to…
0
votes
1 answer

Class cluster with clang: how to use `__attribute__((objc_method_family(none)))`?

I want to implement a class cluster (with ARC), but clang gets in the way. Here is one init method that returns a concrete instance of another class - which is the point of class clusters: @implementation PlaceholderServer - (Server *) init { …
Jean-Denis Muys
  • 6,772
  • 7
  • 45
  • 71
0
votes
1 answer

macOS 12.0.1 (Monterey) XIB fails to load; throwing exception "This coder is expecting the replaced object ... to be returned from NSClassSwapper"

I have XIBs that contain custom objects, one of these is actually a class cluster whose -init method always returns the same singleton object. Basically: - (instancetype)init { self = [super init]; if (HelpLinkHelperSingleton==nil) …
James Bucanek
  • 3,299
  • 3
  • 14
  • 30
0
votes
1 answer

Error with NSNumber Category because of NSCFNumber

I am using WSDL2OBJC for an OS X project. Part of the code generated by WSDL2OBJC adds a category to NSNumber. While I'm using the code I attempt to call the new method on an NSNumber and get an error: +[NSCFNumber xmlNodeForDoc:elementName:]:…
Brian
  • 3,571
  • 7
  • 44
  • 70
0
votes
1 answer

How do we hide private class when using it in Objective-C?

Question How do we hide private class when using it in Objective-C? For example, as described below PrivateFilter is the class I want to hide. CustomFilter is the class I make, which is open. GPUImageFilter is the class public on Github, which is…
allenlinli
  • 2,066
  • 3
  • 27
  • 49
0
votes
6 answers

I created an instance of NSArray, whereas whose class is not NSArray but __NSArrayI?

I have the following code: id anArray = [NSArray arrayWithObjects:@1, @2, nil]; NSLog(@"anArrayClass - %@", [anArray class]); NSLog(@"NSArrayClass - %@", [NSArray class]); And I expect both output are NSArray, however the output turns out to…
Leo
  • 492
  • 1
  • 5
  • 15
0
votes
3 answers

How can i implement the same behaviour as in cluster pattern by apple (NSString and NSCFString)

I am simply writing the following code for testing purpose: NSString *aStr = [[NSString alloc] initWithFormat:@"Foo"]; aStr = [aStr initWithFormat:@"Bar"];//Crashed here I am getting the following error: *** initialization method…
Saurav Nagpal
  • 1,247
  • 1
  • 10
  • 27
-4
votes
1 answer

Why my code did not get into [super init] function?

There are three class Question,Choiceand Blank,and Question is the super class of Choice and Blank. Then, I write some methods as follows: - (instancetype)initWithQuestionType:(NSString *)questionType { NSLog(@"**class:%@",[self class]); …
lxyzk
  • 11
  • 3
1
2