Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 17, 2008, 04:13 PM   #1
Duke Leto
macrumors regular
 
Join Date: Mar 2008
UIKit, XCode, and Obj C help: I dont understand.

I have been looking through sample code and books about the iPhone SDK for about 5 days now. I have limited understanding about these things, even after multiple "blackbox" tests. Questions:

lets say I have:
NSString *input = self.textField.text;
...
How can I test the String's value to another string?

By this is mean why wont this
if(input == @"whatever) { ... }
work?

I also have questions about ViewControllers and CGRects: what are they? When do I use them?

Any help is appreciated because I am frustrated and tired of this.
Duke Leto is offline   0 Reply With Quote
Old Mar 17, 2008, 04:38 PM   #2
admanimal
macrumors 68040
 
Join Date: Apr 2005
How much general programming experience do you have? It sounds like you might want to start with the basics before diving into SDK-specific issues.

To answer your question about the string comparison, you'll want to use [input isEqualToString:@"whatever"].

I'm not entirely familiar with Obj-C, but I'm guessing the reason that input == @"whatever" doesn't work is because input is actually a pointer, so you are comparing a pointer (i.e. a memory address) to the string @"whatever", which semantically doesn't make sense.

Last edited by admanimal; Mar 17, 2008 at 04:45 PM.
admanimal is offline   0 Reply With Quote
Old Mar 17, 2008, 05:08 PM   #3
Duke Leto
Thread Starter
macrumors regular
 
Join Date: Mar 2008
As for programming experience, I have had about four years with Visual Basic, 2 years with ActionScript, about a year with Java, and some other languages.

Thank you for that function though, I have been looking for something like that
Duke Leto is offline   0 Reply With Quote
Old Mar 17, 2008, 06:37 PM   #4
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by Duke Leto View Post
As for programming experience, I have had about four years with Visual Basic, 2 years with ActionScript, about a year with Java, and some other languages.

Thank you for that function though, I have been looking for something like that
Oops. Sorry to disappoint, but you need to learn more. Java, VB or ActionScript will not teach you the most basic principle in Objective C (and almost any C-like language): The concept of pointers and references. That will be the key into understanding why your code doesn't work, and the concept behind memory management in Cocoa. You have a lot of ground to cover before you actually start programming anything, my friend.
Soulstorm is offline   0 Reply With Quote
Old Mar 17, 2008, 07:21 PM   #5
Duke Leto
Thread Starter
macrumors regular
 
Join Date: Mar 2008
Oh well.

Maybe once I am older.

Whatever.
Duke Leto is offline   0 Reply With Quote
Old Mar 17, 2008, 07:22 PM   #6
gifford
macrumors 6502
 
Join Date: Jun 2007
Location: Miserable England
Quote:
Originally Posted by Soulstorm View Post
Oops. Sorry to disappoint, but you need to learn more. Java, VB or ActionScript will not teach you the most basic principle in Objective C (and almost any C-like language): The concept of pointers and references. That will be the key into understanding why your code doesn't work, and the concept behind memory management in Cocoa. You have a lot of ground to cover before you actually start programming anything, my friend.
I wouldnt say the person is doomed in the slightest, presuming you mean AS3 you have at least 2 oo programming languages under your belt (i dont really know much about VB except that its something PC people do).
And both have C like 'for', 'if', 'while's, and both use Objective C 2's '.' to drill down properties. And java uses garbage collection last i knew (not that the iPhone in its current form does).
I dont think he/she will have to much of a problem personally. There are many similarities.

Do a google for 'c structs', it's one of the few skills you may be missing, but you will understand them in 10 mins.

Also, the Cocoa framework can be extremely daunting at first, but will become familiar in time.
__________________
WANTED: ADBE tried for crimes against humanity.

Last edited by gifford; Mar 17, 2008 at 07:29 PM.
gifford is offline   0 Reply With Quote
Old Mar 17, 2008, 07:26 PM   #7
Duke Leto
Thread Starter
macrumors regular
 
Join Date: Mar 2008
I did forget to mention C++ .. and my experience with VB was only to learn about conditionals, variables, functions, and that basic stuff. Then, around .. 5-6th grade, I got a Mac and learned C++ .. . then later I got Flash, then I started messing around with Java, and here I am now.
Duke Leto is offline   0 Reply With Quote
Old Mar 17, 2008, 07:31 PM   #8
gifford
macrumors 6502
 
Join Date: Jun 2007
Location: Miserable England
Quote:
Originally Posted by Duke Leto View Post
I did forget to mention C++ .. and my experience with VB was only to learn about conditionals, variables, functions, and that basic stuff. Then, around .. 5-6th grade, I got a Mac and learned C++ .. . then later I got Flash, then I started messing around with Java, and here I am now.
Then indeed you shall have no problems.
__________________
WANTED: ADBE tried for crimes against humanity.
gifford is offline   0 Reply With Quote
Old Mar 17, 2008, 07:32 PM   #9
cazlar
macrumors 6502
 
Join Date: Oct 2003
Location: Sydney, Australia
If you are set on learning Obj-C and Cocoa, I'd start by playing around by making a simple Mac program before you start on the iPhone. There's a lot more sample code and other resources out there that will help with this. If you come across something and you don't know why it isn't working, hit Apple's docs (in your example, a good read of NSString's docs would have helped find the solution).

Knowing about pointers and references is important, but you can still code with only a vague understanding of them (maybe not code _well_, but whatever).
cazlar is offline   0 Reply With Quote
Old Mar 17, 2008, 07:39 PM   #10
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
If you want to know how to compare NSStrings: Go to developer.apple.com, type NSString in the search box, select "NSString Class Reference" and read it. If you want to know about CGRect: Go to developer.apple.com, type CGRect in the search box, I hope you get the picture.
gnasher729 is offline   0 Reply With Quote
Old Mar 17, 2008, 08:14 PM   #11
Sijmen
macrumors 6502a
 
Join Date: Sep 2005
Of course, there's also Help –> Documentation in Xcode. You can also Option-double click any word in your code to get a quick lookup. As if that's not enough, try Help –> Show Research Assistant if you can afford the screen real estate .
Sijmen is offline   0 Reply With Quote
Old Mar 17, 2008, 08:17 PM   #12
Duke Leto
Thread Starter
macrumors regular
 
Join Date: Mar 2008
Thanks to some of your help, I was able to create a small application that displays an image, and when you press 'next', it moves to the next image. It gets the names of the images from a file that it reads and turns into an array. I know that this is not a very big application, but it has deepened my understanding in many UIKit Elements, and yes, Strings.
Duke Leto is offline   0 Reply With Quote
Old Mar 17, 2008, 08:36 PM   #13
admanimal
macrumors 68040
 
Join Date: Apr 2005
Quote:
Originally Posted by Duke Leto View Post
Oh well.

Maybe once I am older.

Whatever.
No way! Learn now! It sounds like you're on the right track.
admanimal is offline   0 Reply With Quote
Old Mar 17, 2008, 09:35 PM   #14
lucasgladding
macrumors 6502
 
Join Date: Feb 2007
Location: Waterloo, Ontario
 
I would check out Cocoa Programming for Mac OS X from Aaron Hillegass. It is an excellent book and should get you started. There is a 3rd edition in the works that should cover some of the changes for Objective C 2.0.

http://bignerdranch.com/products/cocoa1.shtml
http://www.amazon.com/Cocoa-Programm.../dp/0321503619

You can also check out
http://cocoadevcentral.com/

The other advice is to spend some serious time getting to know delegates, notifications, key value observing, etc. The class references and guides will give you a good idea of what can be done without subclassing.
lucasgladding is offline   0 Reply With Quote
Old Mar 18, 2008, 04:00 AM   #15
Soulstorm
macrumors 68000
 
Soulstorm's Avatar
 
Join Date: Feb 2005
Quote:
Originally Posted by Duke Leto View Post
Oh well.

Maybe once I am older.

Whatever.
I didn't mean to discourage you. And seems like you know C++, so you will have no problems. Check the other posters' responses, and do a revision on pointers.
Soulstorm is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Getting started with XCode/Obj-C but have some outdated books. MikeonTV iPhone/iPad Programming 8 Apr 8, 2014 03:11 PM
UIKit/UIKit.h file not found Jnesbitt82 iPhone/iPad Programming 4 Nov 18, 2013 11:10 PM
I dont understand what I can use AirPort Utility for ? XPcentric Mac OS X Server, Xserve, and Networking 1 Mar 9, 2013 05:13 AM
Help C# .NET student understand Obj-C. egoalterna Mac Programming 3 Jan 30, 2013 03:46 PM
Can't backup to iCloud (I dont understand this) goobot iOS 6 2 Jan 6, 2013 05:23 PM

Forum Jump

All times are GMT -5. The time now is 04:33 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC