Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Use Ioc in iOS and Forms at the same time (XLabs)

$
0
0

I have this in my iOS project

    private void SetIoc()
    {
        var resolverContainer = new SimpleContainer();

        var app = new XFormsAppiOS();
        app.Init(this);

        resolverContainer.Register<IDevice>(t => AppleDevice.CurrentDevice);
        resolverContainer.Register<IMediaPicker, MediaPicker>();
        Resolver.SetResolver(resolverContainer.GetResolver());
    }

I have this in my Forms project

    private void SetIoc()
    {
        var resolverContainer = new SimpleContainer();
        resolverContainer.RegisterSingle<IPositionService, PositionService> ();
        Resolver.SetResolver(resolverContainer.GetResolver());
    }

I now have two different containers with the same name or does the Ioc container solve this? I am new at Ioc, but I can tell my App is acting weird...


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>