OS X and IOS development

Joined
Jun 8, 2013
Messages
158
Reaction score
0
Points
16
Location
Būr said,Egypt
Your Mac's Specs
MacBook Pro (i5)
Guys. why there is diffrance between OS X codes and IOS codes,i know both are woking with the same programming language but some code aren't the same,like this example
--------------------------------------------------------
OS X:
if (textfield.stringvalue=@"Hey") {
(Lable.stringvalue = @"Hello");

----------------------------------------------------------
IOS:
if ([textfield.text isEqual:mad:"Hey]) {
(label.text = @"Hey");
-----------------------------------------------
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
The reason is that NSTextfield and UITextField have different methods, the NSTextfield class was designed years before the UITextField class, so when they started creating the iOS Cocoa Touch frameworks, they changed some of the ways and methods for the UI versions of the NS classes.

The NSTextField does not have a "text" property, and inherits it's "stringValue" property from the NSControl parent class.

And the UITextField does not have a "stringValue" property, nor does the UIControl class from which it inherits.

You can use the "isEqual" or "isEqualTo" on both NS and UI variants, as they both inherit these methods from the NSObject master class.

Regards Mark
 
OP
Yodda_Hunter
Joined
Jun 8, 2013
Messages
158
Reaction score
0
Points
16
Location
Būr said,Egypt
Your Mac's Specs
MacBook Pro (i5)
thanks ;) . well,what does NSLog do? tried a lot to get the answer but didn't understand the meaning.
at least give me a code and tell me what a result i'll gain at the last
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
I dont really understand you're question, putting NSLog statements in you're code prints the results to the debug console window at the bottom of the Xcode IDE, like the example below.

Code:
NSLog(@"Print this string to the debug console");
//OR
NSLog(@"myTextField stringValue = %@", myTextField.stringValue);
//OR
NSLog(@"My Integer variables value = %d", myIntegerVariable);

Does that answer you're question, I'm not sure.

As for you're original question, the differences are not to do with the Objective-C language, but are to do with the differences between the Cocoa and Cocoa Touch Frameworks and their different classes.

Regards Mark
 
OP
Yodda_Hunter
Joined
Jun 8, 2013
Messages
158
Reaction score
0
Points
16
Location
Būr said,Egypt
Your Mac's Specs
MacBook Pro (i5)
I dont really understand you're question, putting NSLog statements in you're code prints the results to the debug console window at the bottom of the Xcode IDE, like the example below.

Code:
NSLog(@"Print this string to the debug console");
//OR
NSLog(@"myTextField stringValue = %@", myTextField.stringValue);
//OR
NSLog(@"My Integer variables value = %d", myIntegerVariable);

Does that answer you're question, I'm not sure.

As for you're original question, the differences are not to do with the Objective-C language, but are to do with the differences between the Cocoa and Cocoa Touch Frameworks and their different classes.

Regards Mark
What i can get from your words that the NSLog isn't a code that gives the User any use,It's only useful for The programmer him self. Well,thanks too,i though it was showing Message for the user but fine thanks but i actually i can ask you how to show a message }:) shall i use try/catch? And if so,what is the code?
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Yes you're correct, the NSLog() statement is for you the programmer to help you debug you're code.

Using @try/@catch/@finally blocks are a bit old fashioned these days, and are more associated with C and Java, but you can use them in objective-C as well, although most Objective-C programmers use the NSError and NSException classes, but error handling is a big subject and you should read some of Apple's documentation pages to learn more.

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/ErrorHandling/ErrorHandling.html#//apple_ref/doc/uid/TP40011210-CH9-SW1

Also if you want to show the User a warning message you should use NSAlert message boxes, and Apple also provides detailed documentation on this subject as well.

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40004001

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Dialog/Tasks/UsingAlerts.html#//apple_ref/doc/uid/20000871-BAJBFGED

Hope this helps

Regards Mark
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top