Question: I'm finding it difficult to understand when it is necessary to create class methods. From what I've read, they are important for creating new objects, but I do not see how. The following class create a simple shape black rectangle. Can anyone show me how to incorporate a class method to do something that I could not do with an instance method?

Shape.h

```
#import <UIKit/UIKit.h>
@interface Shape : UIView; 
- (id) initWithX: (int)xVal andY: (int)yVal;
@end

```

Shape.m

```
#import "Shape.h"
@implementation Shape 
- (id) initWithX:(int )xVal andY:(int)yVal {
self = [super init];    
UIView *shape = [[UIView alloc] initWithFrame:CGRectMake(xVal, yVal, 10, 10)];
shape.backgroundColor = [UIColor blackColor];
[self addSubview:shape];
return self;
}
@end

```

Answer: 
Class methods:

* Can be called when you don't have an instance (yet)
* Aren't operating on an instance (unless one is passed in as a parameter or created by the method) and so don't have access to any particular instance's instance variables.
* Can be overridden in subclasses, unlike a simple function (which otherwise matches the previous points)

As pointed out by the others, I'm sure you use class methods all the time. If nothing else, then `+alloc`.
My answer would be that class methods are very useful when you need to do some utility functions / methods and *don't* need to be doing actions on some specific instance or object. 

For example, in my own code, I typically do class methods in classes where the outcome will be the same no matter which object I could possibly call the method on. Like:

E.G. 

```
@interface MyAppCacheFiles
    + (NSURL *) getFileURLOfLocalCache;
@end

```

These could also be considered convenience methods (e.g. much like `NSString +stringWithFormat:` or `NSArray +arrayWithArray:`).