Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between a protocol and a interface in Objective-c?

I am confused about what the difference is between a protocol and an interface? They both seem to be doing the same thing?

Is it like abstract in C# in that you are required to implement it?

like image 797
user333639 Avatar asked May 12 '10 11:05

user333639


People also ask

What is the difference between a protocol and an interface?

An interface defines how two entities may communicate. A protocol defines how they should communicate and what that communication means.

What is a protocol in Objective-C?

Objective-C allows you to define protocols, which declare the methods expected to be used for a particular situation. This chapter describes the syntax to define a formal protocol, and explains how to mark a class interface as conforming to a protocol, which means that the class must implement the required methods.

What is difference between Objective-C protocol and Swift protocol?

In Objective-C, protocols are declared with the “@protocol” keyword. Below is an example of declaring a protocol containing one required method. In Swift, the syntax is a little different but the idea is the same. In Objective-C, you add the protocol name in angle brackets beside the class interface declaration.

WHAT IS interface and implementation in Objective-C?

Interface and Implementation In Objective C, the file where the declaration of class is done is called the interface file and the file where the class is defined is called the implementation file.


1 Answers

a protocol in Objective-C is the same as an interface in java, if thats what you mean

like image 66
Len Avatar answered Sep 29 '22 14:09

Len