This is a truly odd situation since it is impossible for me to debug because it runs OK in Debug mode !!!
The app consists of a Login page which contains a TableView, a TextField, and a Button. Users select their userID from the table, enter their pin number in the box, and press the login button. The ViewController has been designed in IB as a XIB file. All outlets have been included in the header .h file shown below:
// WARNING
// This file has been generated automatically by Xamarin Studio to
// mirror C# types. Changes in this file made by drag-connecting
// from the UI designer will be synchronized back to C#, but
// more complex manual changes may not transfer correctly.
import <Foundation/Foundation.h>
import <UIKit/UIKit.h>
@interface LoginPage : UIViewController {
UIActivityIndicatorView *_LoginBusyIndicator;
UIButton *_LoginButton;
UITextField *_UsersIDEntry;
UITableView *_UsersSelectionList;
}
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *LoginBusyIndicator;
@property (nonatomic, retain) IBOutlet UIButton *LoginButton;
@property (nonatomic, retain) IBOutlet UITextField *UsersIDEntry;
@property (nonatomic, retain) IBOutlet UITableView *UsersSelectionList;
- (IBAction)OnLoginCommand:(id)sender;
@end
The app crashed the minute I reference the Table, only when packed and installed in release mode into the iPad iOS V8
using System;
using System.Collections.Generic;
using Foundation;
using UIKit;
using TestAPP.Model; // local package
using TestAPP.Helper; // local package
namespace TestAPP
{
public partial class LoginPage : UIViewController
{
String[] empName;
public LoginPage () : base ("LoginPage", null)
{
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
}
public void Reset()
{
UsersIDEntry.Text = "";
UsersIDEntry.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
}
// Called from ApplicationDelegate once all is initialised and ready
public void PopulateEmployeesNames ( List<Employee> employeesData)
{
try
{
LoginBusyIndicator.StopAnimating ();
LoginBusyIndicator.Hidden = true;
empName = new string[employeesData.Count];
int index = 0;
foreach (var employee in employeesData)
empName[index++] = employee.check_name;
// CRASHES HERE. Works OK if these 2 lines are removed
((UIKit.UITableView) UsersSelectionList).Source = new EmployeeLoginTableSource (empName);
UsersSelectionList.ReloadData ();
} catch (Exception e) {
new UIKit.UIAlertView ("Error", "This never gets called!!!" + e.ToString(), null, "Continue").Show ();
}
}
partial void OnLoginCommand(Foundation.NSObject sender)
{
//new UIKit.UIAlertView ("Yo!", "Error DUDE! Server sent some shit!!!", null, "Continue").Show ();
AppDelegate _theAppDelegate = (AppDelegate) UIApplication.SharedApplication.Delegate;
_theAppDelegate.KillLoginAndSwapRootToMain();
}
}
}
Below is the EmployeeLoginTaleSource
using System;
using System.Collections.Generic;
using System.IO;
using Foundation;
using UIKit;
namespace TestAPP.Helper
{
public class EmployeeLoginTableSource : UITableViewSource
{
string[] TableItems;
string cellIdentifier = "TableCell";
public EmployeeLoginTableSource (string[] items)
{
TableItems = items;
}
public override nint NumberOfSections (UITableView tableview)
{
return 1;
}
public override nint RowsInSection (UITableView tableview, nint section)
{
return TableItems.Length;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier);
string item = TableItems[indexPath.Row];
cell.TextLabel.Text = item;
return cell;
}
}
}
Any ideas?