Kalıtım ve Yöntem Geçersiz Kılma
Objective-C'de alt sınıflandırmayla sınıf hiyerarşileri oluşturun, kalıtsal yöntemleri geçersiz kılın ve super kullanarak üst sınıfa çağrı yapın.
Kalıtım ve Yöntem Geçersiz Kılma, CoddyKit'te ücretsiz bir Objective-C iOS Development for Legacy & Enterprise Apps dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Objective-C iOS Development for Legacy & Enterprise Apps öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Objective-C iOS Development for Legacy & Enterprise Apps kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
What is Inheritance?
Inheritance lets a class reuse and extend another class. The new subclass gets all the methods and properties of its superclass, then adds or changes behavior.
Declaring a Subclass
The colon syntax in the interface declares the superclass. Here Dog inherits from Animal.
@interface Dog : Animal
- (void)fetch;
@endInherited Members
A subclass automatically has the superclass's public methods and properties — no need to redeclare them.
Dog *d = [[Dog alloc] init];
[d eat]; // inherited from Animal
[d fetch]; // defined on DogOverriding a Method
To change inherited behavior, redeclare a method with the same name in the subclass. This is overriding.
@implementation Dog
- (void)makeSound {
NSLog(@"Woof!");
}
@endCalling super
Use super to invoke the superclass version, extending rather than replacing its behavior.
- (void)makeSound {
[super makeSound];
NSLog(@"...and wags tail");
}Overriding init
Custom initializers almost always call [super init] first to set up inherited state, then add their own.
- (instancetype)init {
self = [super init];
if (self) {
_legs = 4;
}
return self;
}Polymorphism
A superclass-typed variable can hold any subclass instance. The correct overridden method runs at runtime — this is polymorphism.
Animal *pet = [[Dog alloc] init];
[pet makeSound]; // prints Woof!The instancetype Return
Initializers return instancetype, which adapts to the actual class being created — safer than hardcoding the type.
+ (instancetype)dogWithName:(NSString *)name;Checking Class at Runtime
Objective-C is dynamic. You can ask an object about its class.
if ([pet isKindOfClass:[Dog class]]) {
NSLog(@"It is a dog");
}NSObject the Root
Almost every class ultimately inherits from NSObject, which provides core behavior like alloc, init, isEqual:, and memory management hooks.
Designing Hierarchies
Favor shallow hierarchies. Use inheritance for genuine is-a relationships; for shared behavior across unrelated classes, prefer protocols and categories instead.
Quick Check
Test your inheritance knowledge.
Recap
You learned inheritance in Objective-C:
- Subclass with the
: Superclasssyntax - Inherited methods and properties come for free
- Override methods to change behavior
- Use
superto extend the parent version - Polymorphism picks the right method at runtime
Inheritance and polymorphism are pillars of OOP in Objective-C.
Sıkça Sorulan Sorular
“Kalıtım ve Yöntem Geçersiz Kılma” dersi ücretsiz mi?
Evet — “Kalıtım ve Yöntem Geçersiz Kılma” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Objective-C iOS Development for Legacy & Enterprise Apps kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Objective-C iOS Development for Legacy & Enterprise Apps kursu toplamda 4 dersten oluşur.
“Kalıtım ve Yöntem Geçersiz Kılma” dersinde ne öğreneceğim?
Objective-C'de alt sınıflandırmayla sınıf hiyerarşileri oluşturun, kalıtsal yöntemleri geçersiz kılın ve super kullanarak üst sınıfa çağrı yapın. Objective-C iOS Development for Legacy & Enterprise Apps ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Objective-C iOS Development for Legacy & Enterprise Apps öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Objective-C iOS Development for Legacy & Enterprise Apps, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Kalıtım ve Yöntem Geçersiz Kılma” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Objective-C iOS Development for Legacy & Enterprise Apps dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Objective-C iOS Development for Legacy & Enterprise Apps dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Sınıflar, Nesneler ve Yöntemler
- Özellikler ve Örnek Değişkenleri
- Protokoller ve Kategoriler
- Kalıtım ve Yöntem Geçersiz Kılma