Solved

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

Posted on 2010-08-23
8
908 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

A list of useful business intelligence software.
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

839 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