Reputation: 1037
Example Generic Repository:
public interface IGenericRepository<T> where T : class
{
IQueryable<T> GetAll();
IQueryable<T> FindBy(Expression<Func<T, bool>> predicate);
void Add(T entity);
void Delete(T entity);
void Update(T entity);
void Save();
}
I am looking to use the repository pattern in model layer of my application and can't seem to find much on the subject when comparing c# generic types to objective-c.
Upvotes: 3
Views: 1785
Reputation: 461
As of Xcode 7, Objective C and Swift 2 now support Generics.
They are defined like this
@interface NSArray<__covariant ObjectType>
or
@interface NSDictionary<KeyType, ObjectType>
as taken from the header file of NSArray and NSDictionary. They provide type checking at compile time.
Upvotes: 0
Reputation: 1587
No, there're no generic types in objective-c.
Use of generics is closest to the use of id in Objective-C collection classes such as NSDictionary.
you could refer to C# programming introduced to Objective-C programmers
and this similar question on SO Are there strongly-typed collections in Objective-C?
Upvotes: 1