Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
September 19, 2017, 09:53:31 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1] 2 3 ... 10
 1 
 on: September 13, 2017, 11:35:53 PM 
Started by tleoncio - Last post by Yarnall
Thanks for the tutorial Leon.

 2 
 on: July 07, 2017, 08:11:53 PM 
Started by owenaar - Last post by mitchb
There are other times you will need to do this. In the Preprocessor chapter pg 241 (6th ed) find #define IS_LEAP_YEAR, you will find an explanation of this

Mitch

 3 
 on: July 05, 2017, 03:14:41 PM 
Started by owenaar - Last post by owenaar
Thanks for the response. Is this trailing slash specific to strings or is this mechanism needed in other cases?

 4 
 on: July 04, 2017, 09:37:09 PM 
Started by owenaar - Last post by mitchb
Your code needs to be continuous as in:
 
Code: (Objective-C)
NSLog(@"In Objective-C, lowercase letters are significant.\nmain is where the program execution begins.\nOpen and closed braces enclose program statements in a routine.\nAll program statements must be terminated by a semicolon.");

To format it so you can read it you must add a slash to indicate the line continues. After the return (\n) add another slash (\) to tell the compiler the line continues
 
Code: (Objective-C)
NSLog(@"\n\
              In Objective-C, lowercase letters are significant.\n\
              main is where the program execution begins.\n\
              Open and closed braces enclose program statements in a routine.\n\
              All program statements must be terminated by a semicolon.");

Mitch

 5 
 on: July 03, 2017, 08:58:02 PM 
Started by owenaar - Last post by owenaar
I'm having an issue that I don't understand. Here's my code:

Code: (Objective-C)
//First program example

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
@autoreleasepool {
NSLog (@"In Objective-C, lowercase letters are significant.\n
main is where the program execution begins.\n
Open and closed braces enclose program statements in a routine.\n
All progam statements must be terminated by a semicolon." );
}
return 0;
}

This fails to compile with the following errors:

Code: (Objective-C)
main2.6-textedit.m:8:11: warning: missing terminating '"' character [-Winvalid-pp-token]
                NSLog (@"In Objective-C, lowercase letters are significant.\n
                        ^
main2.6-textedit.m:8:10: error: unexpected '@' in program
                NSLog (@"In Objective-C, lowercase letters are significant.\n
                       ^
main2.6-textedit.m:11:60: warning: missing terminating '"' character [-Winvalid-pp-token]
                        All progam statements must be terminated by a semicolon." );
                                                                                ^
main2.6-textedit.m:14:2: error: expected '}'
}
 ^
main2.6-textedit.m:6:1: note: to match this '{'
{
^
2 warnings and 2 errors generated.

If I put all of the lines of the string on a single line, it compiles and works:

Code: (Objective-C)
//First program example

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
@autoreleasepool {
NSLog (@"\nIn Objective-C, lowercase letters are significant.\nmain is where the program execution begins.\nOpen and closed braces enclose program statements in a routine.\nAll progam statements must be terminated by a semicolon." );
}
return 0;
}

I'm using sublime2 as my text editor saving to a UTF-8 file on a Mac. Is there some hidden character return encoding that I'm running into? Is whitespace significant?

 6 
 on: April 19, 2017, 01:15:07 AM 
Started by clouded - Last post by LavrinPristazh
In the 7th version of Xcode, you should type"clang -fobjc-arc copy.m -o copy" to compile in the Terminal.

 7 
 on: April 05, 2017, 03:11:30 AM 
Started by tleoncio - Last post by LWhisley
I am having no problems maybe their server was down try again if still nothing then uninstall and reinstall it maybe a file got corrupted

 8 
 on: February 24, 2017, 06:50:44 AM 
Started by pif - Last post by nunof32
Hello,

I just posted something very similar to this (Feb. 24, 2017) before I noticed your post.

I think your concern is valid. Have you had a full explanation on how and why this works (or not).

Regards,

nunof32

 9 
 on: February 24, 2017, 06:44:33 AM 
Started by nunof32 - Last post by nunof32
Hello, I'm trying to learn Objective-C and am stuck in Chapter 8. Would appreciate if someone can get me out of the rut.

My worries concern Class Rectangle that is introduced in this chapter (Cool.

1. First I'm troubled by the fact that nowhere is it said that Properties height and width of Rectangle must not be negative. If they can be negative, the definition of Property origin (coordinates of the lower left corner of the rectangle) makes that origin has to be recomputed (and the negative values of height / with converted to positives) each time height and width are (re)set. There are also a number of interesting complications if the user sets first the height and the width of the rectangle before setting its origin.

To avoid these complications I would like to ensure that height and width are >= 0. But as author Kochan has imposed earlier that these Properties are @synthesized I assume that the author does not wish that I tinker with their accessor methods ...

Any views on this ?

2. More fundamental : setOrigin method implementation. The book usefully highlights the problem that can occur if this method just copies into origin (which is a pointer) the parameter pt (also a pointer) that is passed to it : both pointers point to the same values and if the values that pt points to are changed so will the values that origin points to.

The book says that the solution is for the instance to own its own origin XYPoint. This is achieved through a preliminary statement at the beginning of the method

origin = [[XYPoint] alloc] init];

Very well. Now we have created our own XYPoint which origin points to.

My problem is that this looks strange. The statement is put inside the setOrigin method. Presumably, the XYPoint that it creates is created in memory space that belongs to the method for the duration of its execution. By the time the method returns, this space is reverted to the 'space unused' pool and nothing guarantees us that the space where the x and y property values of origin are stored will not be overwritten by someone else.

I would have thought that the right solution would be to make the allocation / initialization of the variable along with its declaration in this way :

@interface : Rectangle
{
   XYPoint origin * = [[XYPoint alloc] init]];
}

but this is not allowed.


Can someone please shed some light into this ?

Many thanks in advance.

Pages: [1] 2 3 ... 10
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.