Results 1 to 6 of 6
  1. #1


    Member Since
    Jun 08, 2013
    Location
    Būr said,Egypt
    Posts
    158
    Specs:
    MacBook Pro (i5)
    OS X and IOS development
    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:@"Hey]) {
    (label.text = @"Hey");
    -----------------------------------------------

  2. #2

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    193
    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

  3. #3


    Member Since
    Jun 08, 2013
    Location
    Būr said,Egypt
    Posts
    158
    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

  4. #4

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    193
    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

  5. #5


    Member Since
    Jun 08, 2013
    Location
    Būr said,Egypt
    Posts
    158
    Specs:
    MacBook Pro (i5)
    Quote Originally Posted by Mark FX View Post
    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?

  6. #6

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    193
    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/...011210-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/...uid/TP40004001

    https://developer.apple.com/library/...00871-BAJBFGED

    Hope this helps

    Regards Mark

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. iOS app development
    By Nola26 in forum iOS and Apps
    Replies: 1
    Last Post: 06-15-2012, 05:59 AM
  2. New to iOS development. Where do I start?
    By TheGreatApple in forum iOS Development
    Replies: 3
    Last Post: 04-03-2012, 02:27 PM
  3. Requirements for iOS development
    By nongeek in forum iOS Development
    Replies: 2
    Last Post: 08-25-2011, 12:18 PM
  4. One Year Later, iOS is Still the Best Development Platform
    By OneMoreThing... in forum Apple Rumors and Reports
    Replies: 1
    Last Post: 05-17-2011, 03:45 PM
  5. iOS Development-Getting tools from Apple
    By markwco in forum iOS and Apps
    Replies: 5
    Last Post: 02-15-2011, 11:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •