gpt4 book ai didi

c# - objective-c 是否具有类似于 c# 的泛型类型(和约束)?

转载 作者:行者123 更新时间:2023-12-04 18:09:56 30 4
gpt4 key购买 nike

示例通用存储库:

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();
}

我希望在我的应用程序的模型层中使用存储库模式,但在将 C# 泛型类型与 Objective-C 进行比较时似乎找不到太多关于该主题的内容。

最佳答案

不,objective-c 中没有泛型类型。

Use of generics is closest to the use of id in Objective-C collection classes such as NSDictionary.

你可以引用 C# programming introduced to Objective-C programmers

以及关于 SO 的类似问题 Are there strongly-typed collections in Objective-C?

关于c# - objective-c 是否具有类似于 c# 的泛型类型(和约束)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16659750/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com