Solved

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

Posted on 2010-08-23
8
907 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
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

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
 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

I previously wrote an article addressing the use of UBCD4WIN and SARDU. All are great, but I have always been an advocate of SARDU. Recently it was suggested that I go back and take a look at Easy2Boot in comparison.
If your app took Google’s lash recently, here are the 5 most likely reasons.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

777 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