Solved

Using XCode and Cocoa Touch - How do find info on debugging and implementing classes properly for iPhone?

Posted on 2010-08-23
8
906 Views
Last Modified: 2013-12-12
I'm relatively new to development in XCode and Interface Builder for iPhone.  I've developed a little with C# in .NET for work.
I'm wanting to know a systematic approach to debugging and using classes properly in development.

For example, I'm writing an app, and I'm wanting to use a class I haven't implemented before, UIWebView.  I used the apple developer documentation in XCode to learn how to use it, but I've not been able to get a page running in the UIWebView yet.  The simulation runs without warnings or errors, but nothing loads in the UIWebView.

How I should go about solving this sort of problem?  What should I read, or what debugging steps should I take to get the UIWebView, or any class implemented properly?

I could post my code, but I more concerned about the proper steps to solving this type of issue rather than just to solve this example.
0
Comment
Question by:mattasks
  • 4
  • 4
8 Comments
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33498779
You need to show the code. I attached an example that you may understand already.
Any question you have, you can simply ask here.

Here is a tutorial about UIWebView:
UIWebView Tutorial
http://www.iphonesdkarticles.com/2008/08/uiwebview-tutorial.html

It's simple and works fine. It will take you few minutes to read and implement this program.

There is a debugger in Xcode. It's not the same as in Visual Studio and it will take a while to understand it and start to use it. Command + backslash set a breakpoint. You can use NSLog and it will help you to develop. The log messages you will see in the console. Actually you need to arrange the IDE per your needs. For now, simply use the Xcode menu and Google search for everything.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
  
	CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0);
	UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
	[webView setBackgroundColor:[UIColor whiteColor]];
	NSString *urlAddress = @"http://www.google.com";
	NSURL *url = [NSURL URLWithString:urlAddress];
	NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
	[webView loadRequest:requestObj];
	[window addSubview:webView]; 
	[webView release];	
    [window makeKeyAndVisible];
	
	return YES;
}

Open in new window

0
 

Author Comment

by:mattasks
ID: 33498850
I'm asking about the steps to solve this type of problem.  For example, if your code above compiled fine, returned no errors or warnings, but the UIWebView wouldn't load a page (just stayed as the plain whiteColor background), what steps would you take to debug it?  Where would you put brakepoints and what would you be looking for in an inspector?
Thanks
0
 

Author Comment

by:mattasks
ID: 33498863
I've done a few applications, and have mostly used tutorials and examples to help debug.  But I'm looking for a better practice to use when I can't find examples.  What are some systematic checks that I should do when this sort of problem occurs?
0
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 33498877
1. Use NSLog for each step.
2. Set a breakpoint new NSString *urlAddress = @"http://www.google.com"; and check the variables and function returns. In may cases you can check everything in Mac OS X application. The change is simple AppKit instead of UIKit.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 33

Assisted Solution

by:pgnatyuk
pgnatyuk earned 500 total points
ID: 33498885
For such mistakes you use NSLog and debugger.
Xcode contains instruments for more complicated cases: memory leak detection, profiling, etc.
0
 

Author Comment

by:mattasks
ID: 33499356
Ok, thanks for those suggestions.  I'm becoming more familiar with the debugger now.
I'm trying to use breakpoints and NSLog within viewDidLoad in the view controller, but I can't get the debugger to stop at the breakpoints.  NSLog doesn't seem to write to the console either.  (I've got NSLog working successfully in another method)

- (void)viewDidLoad:(id)sender {
      NSLog(@"inside viewDidLoad override");
      [super viewDidLoad];
}

Any ideas?
0
 

Author Closing Comment

by:mattasks
ID: 33499456
Thanks for the help.  This has helped me start using the debugger and Console.  I have more questions, but I'll start them in new questions so that I can award the points for this solution first.

Thanks,
Matt
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 33500061
You are welcome
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
remove chinese softwares 22 109
Global Keyboard Hooks Blocked 4 70
Salesforce Campaign - 4,500 members 5 64
outlook office 365 8 84
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now