[MonoTouch] All UI Variables are null after editing xib in XCode4.1
Guido Van Hoecke
guivho at gmail.com
Mon Oct 10 04:13:52 EDT 2011
I have a xib with a Label that had no outlet defined for it.
Clicking on the xib file within MD2.8, it launches XCode4.1 build 4B110
I open the assistant editor and control-drag my label to the end of
the header file.
I name the label 'languagesLabel' and click connect.
I hit Cmd-S and Cmd-W to save the changes and dismiss the interface editor.
My app now crashes with NPE:
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException:
Object reference not set to an instance of an object
at MTApp.SelectLooks.RefreshUi () [0x00089] in
/Users/guivho/Mono/MTApp/SelectLooks.xib.cs:71
at MTApp.SelectLooks.ViewWillAppear (Boolean animated) [0x00029] in
/Users/guivho/Mono/MTApp/SelectLooks.xib.cs:49
at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_bool
(intptr,intptr,intptr,b2011-10-10 09:59:51.990
GADBannerHandler.cs:StopBannerDisplay(33)
2011-10-10 09:59:51.992 SelectLooks.xib.cs:ViewWillAppear(45)
ool)
at MonoTouch.UIKit.UINavigationController.PushViewController
(MonoTouch.UIKit.UIViewController viewController, Boolean animated)
[0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UINavigationController.g.cs:123
at MTApp.TableViewSource.NavRowSelected (MCiOSSubs.NavItem navItem)
[0x00098] in /Users/guivho/Mono/MTApp/TableViewSource.cs:222
at MTApp.TableViewSource.RowSelected (MonoTouch.UIKit.UITableView
tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00051] in
/Users/guivho/Mono/MTApp/TableViewSource.cs:191
at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication:UIApplicationMain
(int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args,
System.String principalClassName, System.String delegateClassName)
[0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at MonoTouch.UIKit.UIApplication.Main (System.String[] args)
[0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:34
at MTApp.Application.Main (System.String[] args) [0x00000] in
/Users/guivho/Mono/MTApp/Main.cs:30
Further investigation showes that all outlet variables are null, and
the app crashes when addressing the 'looksTabeView'!
I attach the udiff showing the changes in the designer. Clearly it
switched from xcode3 to xcode4 format.
Bottom line: I'm stuck! I need to define an outlet for this label so
that I can continue coding.
Did I do something wrong? I must have, since I didn't see any reports
yet about this kind of problem...
Any suggestions would be highly appreciated!
TIA,
Guido
--- /Users/guivho/Mono/MTApp/SelectLooks.xib.designer.cs (base)
+++ /Users/guivho/Mono/MTApp/SelectLooks.xib.designer.cs (working copy)
@@ -1,12 +1,60 @@
-// ------------------------------------------------------------------------------
-// <autogenerated>
-// This code was generated by a tool.
-// Mono Runtime Version: 4.0.30319.1
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </autogenerated>
-// ------------------------------------------------------------------------------
+// WARNING
+//
+// This file has been generated automatically by MonoDevelop to store
outlets and
+// actions made in the Xcode designer. If it is removed, they will be lost.
+// Manual changes to this file may not be handled correctly.
+//
+using MonoTouch.Foundation;
+
+namespace MTApp
+{
+ [Register ("SelectLooks")]
+ partial class SelectLooks
+ {
+ [Outlet]
+ MonoTouch.UIKit.UIView view { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIPickerView picker { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UITableView looksTableView { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIView imagesView { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView image0a { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView image1a { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView image0c { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView image1c { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView image0e { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView image1e { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView imagebg { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView imagebgprevious { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UIImageView imagebglast { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UILabel colorsLabel { get; set; }
+
+ [Outlet]
+ MonoTouch.UIKit.UILabel imagesLabel { get; set; }
namespace MTApp {
@@ -8,222 +56,7 @@
// </autogenerated>
// ------------------------------------------------------------------------------
-namespace MTApp {
-
-
- // Base type probably should be MonoTouch.UIKit.UIViewController or subclass
- [MonoTouch.Foundation.Register("SelectLooks")]
- public partial class SelectLooks {
-
- private MonoTouch.UIKit.UIView __mt_view;
-
- private MonoTouch.UIKit.UIPickerView __mt_picker;
-
- private MonoTouch.UIKit.UITableView __mt_looksTableView;
-
- private MonoTouch.UIKit.UIView __mt_imagesView;
-
- private MonoTouch.UIKit.UIImageView __mt_image0a;
-
- private MonoTouch.UIKit.UIImageView __mt_image1a;
-
- private MonoTouch.UIKit.UIImageView __mt_image0c;
-
- private MonoTouch.UIKit.UIImageView __mt_image1c;
-
- private MonoTouch.UIKit.UIImageView __mt_image0e;
-
- private MonoTouch.UIKit.UIImageView __mt_image1e;
-
- private MonoTouch.UIKit.UIImageView __mt_imagebg;
-
- private MonoTouch.UIKit.UIImageView __mt_imagebgprevious;
-
- private MonoTouch.UIKit.UIImageView __mt_imagebglast;
-
- private MonoTouch.UIKit.UILabel __mt_colorsLabel;
-
- private MonoTouch.UIKit.UILabel __mt_imagesLabel;
-
- #pragma warning disable 0169
- [MonoTouch.Foundation.Connect("view")]
- private MonoTouch.UIKit.UIView view {
- get {
- this.__mt_view = ((MonoTouch.UIKit.UIView)(this.GetNativeField("view")));
- return this.__mt_view;
- }
- set {
- this.__mt_view = value;
- this.SetNativeField("view", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("picker")]
- private MonoTouch.UIKit.UIPickerView picker {
- get {
- this.__mt_picker =
((MonoTouch.UIKit.UIPickerView)(this.GetNativeField("picker")));
- return this.__mt_picker;
- }
- set {
- this.__mt_picker = value;
- this.SetNativeField("picker", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("looksTableView")]
- private MonoTouch.UIKit.UITableView looksTableView {
- get {
- this.__mt_looksTableView =
((MonoTouch.UIKit.UITableView)(this.GetNativeField("looksTableView")));
- return this.__mt_looksTableView;
- }
- set {
- this.__mt_looksTableView = value;
- this.SetNativeField("looksTableView", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("imagesView")]
- private MonoTouch.UIKit.UIView imagesView {
- get {
- this.__mt_imagesView =
((MonoTouch.UIKit.UIView)(this.GetNativeField("imagesView")));
- return this.__mt_imagesView;
- }
- set {
- this.__mt_imagesView = value;
- this.SetNativeField("imagesView", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("image0a")]
- private MonoTouch.UIKit.UIImageView image0a {
- get {
- this.__mt_image0a =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("image0a")));
- return this.__mt_image0a;
- }
- set {
- this.__mt_image0a = value;
- this.SetNativeField("image0a", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("image1a")]
- private MonoTouch.UIKit.UIImageView image1a {
- get {
- this.__mt_image1a =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("image1a")));
- return this.__mt_image1a;
- }
- set {
- this.__mt_image1a = value;
- this.SetNativeField("image1a", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("image0c")]
- private MonoTouch.UIKit.UIImageView image0c {
- get {
- this.__mt_image0c =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("image0c")));
- return this.__mt_image0c;
- }
- set {
- this.__mt_image0c = value;
- this.SetNativeField("image0c", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("image1c")]
- private MonoTouch.UIKit.UIImageView image1c {
- get {
- this.__mt_image1c =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("image1c")));
- return this.__mt_image1c;
- }
- set {
- this.__mt_image1c = value;
- this.SetNativeField("image1c", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("image0e")]
- private MonoTouch.UIKit.UIImageView image0e {
- get {
- this.__mt_image0e =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("image0e")));
- return this.__mt_image0e;
- }
- set {
- this.__mt_image0e = value;
- this.SetNativeField("image0e", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("image1e")]
- private MonoTouch.UIKit.UIImageView image1e {
- get {
- this.__mt_image1e =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("image1e")));
- return this.__mt_image1e;
- }
- set {
- this.__mt_image1e = value;
- this.SetNativeField("image1e", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("imagebg")]
- private MonoTouch.UIKit.UIImageView imagebg {
- get {
- this.__mt_imagebg =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("imagebg")));
- return this.__mt_imagebg;
- }
- set {
- this.__mt_imagebg = value;
- this.SetNativeField("imagebg", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("imagebgprevious")]
- private MonoTouch.UIKit.UIImageView imagebgprevious {
- get {
- this.__mt_imagebgprevious =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("imagebgprevious")));
- return this.__mt_imagebgprevious;
- }
- set {
- this.__mt_imagebgprevious = value;
- this.SetNativeField("imagebgprevious", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("imagebglast")]
- private MonoTouch.UIKit.UIImageView imagebglast {
- get {
- this.__mt_imagebglast =
((MonoTouch.UIKit.UIImageView)(this.GetNativeField("imagebglast")));
- return this.__mt_imagebglast;
- }
- set {
- this.__mt_imagebglast = value;
- this.SetNativeField("imagebglast", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("colorsLabel")]
- private MonoTouch.UIKit.UILabel colorsLabel {
- get {
- this.__mt_colorsLabel =
((MonoTouch.UIKit.UILabel)(this.GetNativeField("colorsLabel")));
- return this.__mt_colorsLabel;
- }
- set {
- this.__mt_colorsLabel = value;
- this.SetNativeField("colorsLabel", value);
- }
- }
-
- [MonoTouch.Foundation.Connect("imagesLabel")]
- private MonoTouch.UIKit.UILabel imagesLabel {
- get {
- this.__mt_imagesLabel =
((MonoTouch.UIKit.UILabel)(this.GetNativeField("imagesLabel")));
- return this.__mt_imagesLabel;
- }
- set {
- this.__mt_imagesLabel = value;
- this.SetNativeField("imagesLabel", value);
- }
- }
+ [Outlet]
+ MonoTouch.UIKit.UILabel languagesLabel { get; set; }
}
}
More information about the MonoTouch
mailing list