我在sceneDelegate中声明了一个变量,并想从NSObject访问该变量。我们可以从UIView或UIViewController做到这一点,但是不知道如何在NSObject中做到这一点。
是否可以访问此变量?
答案 0 :(得分:0)
如果应用程序中只有一个场景,则可以使用
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "EF1001:Internal EF Core API usage.", Justification = "Workaround")]
public class ModelDiffer : MigrationsModelDiffer
{
public ModelDiffer(
IRelationalTypeMappingSource typeMappingSource,
IMigrationsAnnotationProvider migrationsAnnotations,
IChangeDetector changeDetector,
IUpdateAdapterFactory updateAdapterFactory,
CommandBatchPreparerDependencies commandBatchPreparerDependencies) :
base(typeMappingSource, migrationsAnnotations, changeDetector, updateAdapterFactory, commandBatchPreparerDependencies)
{
}
//FIXME Remove when https://github.com/aspnet/EntityFrameworkCore/issues/18943 is deployed
public override IReadOnlyList<MigrationOperation> GetDifferences(IModel source, IModel target)
{
return base.GetDifferences(source, target)
.Where(o => !(o is UpdateDataOperation))
.ToList();
}
}
services.AddDbContextPool<Context>(o =>
{
o.ReplaceService<IMigrationsModelDiffer, ModelDiffer>();
o.UseSqlServer(connectionString, ...
}