---
title: "Abstract class in cocoa"  
description: "Abstract class in cocoa"  
author: "Tarun Kumar"  
published: 2015-11-24  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/22914/abstract-class-in-cocoa  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Abstract class in cocoa

Cocoa doesn't provide anything called abstract. We can create a class abstract which gets check only at runtime, compile time this is not checked.

```
@interface AbstractClass : NSObject@end@implementation AbstractClass+ (id)alloc{if (self == [AbstractClass class]) {NSLog(@”Abstract Class cant be used”);}return [super alloc];@end
```

## Answers

### Answer by Tarun Kumar

Cocoa doesn't provide anything called abstract. We can create a class abstract which gets check only at runtime, compile time this is not checked.

```
@interface AbstractClass : NSObject@end@implementation AbstractClass+ (id)alloc{if (self == [AbstractClass class]) {NSLog(@”Abstract Class cant be used”);}return [super alloc];@end
```


---

Original Source: https://www.mindstick.com/interview/22914/abstract-class-in-cocoa

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
