Not enough arguments error

Error: Not Enough Arguments Error

Details: Failed invoking <symbol>

Stack:

  - initialize() at C:\Users\Me\eclipse-workspace\FileLocations\Map Widget\source\MapWidgetDelegate.mc:16 0x10001253

  - getInitialView() at C:\Users\Me\eclipse-workspace\FileLocations\Map Widget\source\MapWidgetApp.mc:31 0x100000ab

The bits in bold are where the errors complain about when the sim runs but i’m not sure what to do to fix this, any help is much appreciated.

This is the App.mc


using Toybox.WatchUi;

using Toybox.Application;

using Toybox.Position;

using Toybox.Sensor;

using Toybox.Timer;

 

class MapWidgetApp extends Application.AppBase {

var positionView;

var del;

 

 

     function initialize() {

        AppBase.initialize();

    }

 

   //! onStart() is called on application start up

   function onStart(state)

   {Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));

    }

 

    //! onStop() is called when your application is exiting

    function onStop(state)

   {Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));

    }

   

   function onPosition(info) {

        positionView.setPosition(info);

    }

    // Return the initial view of your application here

    function getInitialView() {

   del = new MapWidgetDelegate();

    positionView = new MapWidgetView();

    var view = new MapWidgetView();

    var delegate = new MapWidgetDelegate(view);

   

      return [ positionView, del, view, delegate  ];

    }

 

}

This is the Delegate.mc

using Toybox.Attention;

using Toybox.WatchUi;

using Toybox.Position;

 

class MapWidgetDelegate extends WatchUi.BehaviorDelegate {

 

var posnInfo = null;

var aView;

 

 

     function initialize(view) {

        WatchUi.BehaviorDelegate.initialize();

        aView = view;

    }

    // Push a text picker if the up button is pressed

    // or the screen receives a tap.

 

    function onKey(evt) {

var key = evt.getKey();

if (key == WatchUi.KEY_DOWN) {

aView.myFunct();

}

}

}

 

Sorry about the code of both MC files, its a bit messy because its basically a bunch of code from open source, samples and shared bits found here squashed together

  • This is kind of hard to read and understand.  Have you looked at the mapsample in the SDK?  Not sure why you are returning two views and two deligates in getInitialView for example, where positionView and view seem to be the same thing.

    Instead of:

        function getInitialView() {
    
       del = new MapWidgetDelegate();
        positionView = new MapWidgetView();
    
        var view = new MapWidgetView();
    
        var delegate = new MapWidgetDelegate(view);
    
       
    
          return [ positionView, del, view, delegate  ];
    
        }

    It looks like you should just do:

        function getInitialView() {
            var view = new MapWidgetView();
            var delegate = new MapWidgetDelegate(view);
            return [ view, delegate  ];
        }

    The reason you got the error on

    del = new MapWidgetDelegate();

    is you need to pass a argument (the view) as you do when you create the delegate the second time. But there is no reason to create the view and delegate twice to begin with.