Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

This class is not key value coding-compliant for the key

$
0
0

Hi,

I'm a beginner at C# and very new to iOS and Xamarin - but am teaching myself and making some progress towards my first app (a battle calculator for an iOS game). I have two issues which I have been unable to resolve on my own after hours of fiddling and scouring the web.

For my root controller I have a TabBarController which has 2 NavigationControllers and one standard ViewController set as its tabs. The page that is being loaded has several buttons of which I have one wired via an outlet to push a new ViewController onto the NavigationController in the first tab. Loading this up in the simulator has no problems. Deploying to my device throws me this exception:

Objective-C exception thrown. Name: NSUnknownKeyException Reason: [<screenAttacker 0x16593570> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnWall.

I've seen that this could be caused by setting a Main Interface in the info.plist and can confirm that both the iPad and iPhone sections are blank for this field.

Also this can be caused by outlets not being deleted correctly or objects being linked to outlets which no longer exist etc. I deleted all entries in the .h and .m files and removed all outlet connections (in deleted and re-added all buttons also) and created a fresh one.

The second (and I'm assuming unrelated) issue is warnings MT3005 & MT3006 - also only when deploying to device:

Warning MT3005: The dependency 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' of the assembly 'monotouch, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' was not found. Please review the project's references. (MT3005)

Warning MT3006: Could not compute a complete dependency map for the project. This will result in slower build times because Xamarin.iOS can't properly detect what needs to be rebuilt (and what does not need to be rebuilt). Please review previous warnings for more details. (MT3006)

Any help with these two issues would be greatly appreciated. Its driving me nuts. Below I've included that AppDelegate, ViewController and .h / .m files associated. Please let me know if you need any more info.

Cheers!

AppDelegate.cs:

`using System; using System.Collections.Generic; using System.Linq; using MonoTouch.Foundation; using MonoTouch.UIKit;

namespace KEBC { [Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate {

    public static UIWindow window;
    public static UITabBarController rootTab;
    public static UINavigationController navAttacker;
    public static UINavigationController navDefender;
    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {

        window = new UIWindow (UIScreen.MainScreen.Bounds);

        screenAttacker screenAttacker = new screenAttacker ();
        screenDefender screenDefender = new screenDefender ();
        screenSummary screenSummary = new screenSummary ();
        navAttacker = new UINavigationController (screenAttacker);
        navDefender = new UINavigationController (screenDefender);
        navAttacker.Title = "Attacker";
        navDefender.Title = "Defender";
        screenSummary.Title = "Summary";


        rootTab = new UITabBarController ();
        UIViewController[] tabs = new UIViewController[] {
            navAttacker,
            navDefender,
            screenSummary
        };
        rootTab.ViewControllers = tabs;

        window.RootViewController = rootTab;

        // make the window visible
        window.MakeKeyAndVisible ();

        return true;
    }
}

}`

screenAttacker.cs:

`using System; using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit;

namespace KEBC { public partial class screenAttacker : UIViewController { static bool UserInterfaceIdiomIsPhone { get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; } }

    public screenAttacker ()
        : base (UserInterfaceIdiomIsPhone ? "screenAttacker_iPhone" : "screenAttacker_iPad", null)
    {
    }

    public override void DidReceiveMemoryWarning ()
    {

        base.DidReceiveMemoryWarning ();

    }

    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear (animated);
        this.NavigationController.SetNavigationBarHidden (true, animated);
    }

    public override void ViewWillDisappear(bool animated)
    {
        base.ViewWillAppear (animated);
        this.NavigationController.SetNavigationBarHidden (false, animated);
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        this.Title = "Attacker";
        btnWall.TouchUpInside += (sender, e) => {
            AppDelegate.navAttacker.PushViewController(new screenWall(), true);
        };

    }

}

}`

screenAttack.h:

`#import <Foundation/Foundation.h>

import <UIKit/UIKit.h>

@interface screenAttacker : UIViewController { }

@property (retain, nonatomic) IBOutlet UIButton *btnWall;

@end`

screenAttacker.m:

`#import "screenAttacker.h"

@implementation screenAttacker

  • (void)dealloc { [_btnWall release]; [super dealloc]; } @end`

Viewing all articles
Browse latest Browse all 204402

Trending Articles



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