Amazon.com Widgets Recent Posts
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 27, 2015, 01:11:37 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Recent Posts
Pages: 1 2 [3] 4 5 ... 10

 21 
 on: February 24, 2015, 03:13:20 PM 
Started by jonr - Last post by jonr
In chapter 15 in Table 15.1 there is a 3 column list.  The question I have is about the first two.  The first column lists creation and initialization class methods, and the second column lists initialization instance methods (you have to use alloc with these, as you would expect).

So, what's considered the best way?  From looking at this, I'm not sure why anyone would ever choose to use alloc + an initialization instance method when you could easily just use the creation and initialization class method and do it in one step.  You can't change the value of a previously created NSNumber object. Therefore using an instance initialization method (e.g. initWithChar) on an NSNumber object with a value is essentially useless.  In other words, you can't use it 'after the fact' and change the value.

The book shows all of these possible ways to do this but didn't offer much on the plusses or minuses of either approach.  Does anyone have any opinions on this?  Thanks for any info.

 22 
 on: February 24, 2015, 01:43:20 PM 
Started by ohh - Last post by pearlofEn
It appears that GG can identify complex numbers and perform complex arithmetic and complex valued functions on complex numbers individually, but I havent found a way to define a complex valued function of a complex variable.

For example  how does one define a mobius function,f, of a complex variable z=xiy  when z_1 = 23i, z_2 = 1-2i, z_3 = 3-i, so that fz = z_1 z_2 z/z_3z ?

 23 
 on: February 22, 2015, 06:12:04 AM 
Started by MikeF - Last post by pearlofEn
Thats wonderful I look forward to the new features and developments.

Thanks very much.

 24 
 on: February 17, 2015, 10:55:28 PM 
Started by barrettlikespizza - Last post by mitchb
A little question I have, is why did you write that last NSlog statement in the program section? Call your print method instead.

Mitch

 25 
 on: February 17, 2015, 04:24:52 PM 
Started by barrettlikespizza - Last post by BrianLawson
There is nothing wrong with your code. lldb is the debugger, it appears that you have a breakpoint set on line 24, fuelcells = f;

Click on the little tab marker at line 24 and drag it out of the editor pane to remove it and your program should run fine.

 26 
 on: February 17, 2015, 11:41:33 AM 
Started by barrettlikespizza - Last post by barrettlikespizza
Here is a screen shot of the Thread error and the lldb output on the bottom.

Thanks for your time if anyone has a moment to check this!

It says "build successful" but it's obviously not doing what it's intended to.

 27 
 on: February 17, 2015, 11:30:25 AM 
Started by barrettlikespizza - Last post by barrettlikespizza
Code: (Objective-C)
#import <Foundation/Foundation.h>

//interface section to declare the class and instance methods

@interface Spaceship: NSObject

-(void) print;
-(void) insertFuel: (int) f;
-(void) insertHumans: (int) h;
-(int) checkFuel;
-(int) countHumans;

@end

// and here comes the implementation section!

@implementation Spaceship
{
    int fuelcells;
    int humans;
}
-(void) insertFuel: (int) f
{
    fuelcells = f;
}
-(void) insertHumans:(int)h
{
    humans = h;
}
-(void) print
{
    NSLog(@"There are %i remaining fuel cells and %i humans on the ship.", fuelcells, humans);
}

-(int) checkFuel
{
    return fuelcells;
}
-(int) countHumans
{
    return humans;
}

@end

// Program section

int main(int argc, const char * argv[]) {
    @autoreleasepool {

        Spaceship *myShip = [[Spaceship alloc] init];
       
        [myShip insertFuel:56];
        [myShip insertHumans:23];
       
        NSLog(@"There are %i fuel cells left, and %i humans on board.", [myShip checkFuel], [myShip countHumans]);
       
    }
    return 0;
}

I'm getting a "Thread 1:breakpoint 1.1" error on the line "fuelcells=f;"

The output is (lldb) and it doesn't show my NSLog.

However, when I delete the line "[myShip insertFuel:56];" in the program section, it prints a value of 0 for fuel, and a correct value for humans. and the (lldb) part goes away.

What is wrong with this code? I don't know what lldb, and I've been deleting and re-editing this for an hour and a half.

Please help, thank you.

 28 
 on: February 17, 2015, 07:54:05 AM 
Started by slackie - Last post by BrianLawson
I'm not on Windows and I am unfamiliar with mingw and cygwin so I can not be certain but it seems to me that the runtimes for those systems are not initializing the arrays with zeros when they are declared. What you are seeing in the uninitialized array entries is whatever happened to be in that memory location when the printf statement is executed. This also would explain why the un-initied values change from one run to the next.

I'm seeing the same thing when I run a similar program in Xcode.

 29 
 on: February 17, 2015, 01:25:31 AM 
Started by slackie - Last post by slackie
i heve been make program so the result like this

values[0] = 197
values[1] = 0
values[2] = -101
values[3] = 547
values[4] = 0
values[5] = 350
values[6] = 0
values[7] = 0
values[8] = 0
values[9] = 35

this is the program

// working with array

#include <stdio.h>

int main (void)
{

   int values[10];
   int index;
   int i;   

   for ( i =0; i<10; ++i)
   values = 0;

   values[0] = 197;
   values[2] = -100;
   values[5] = 350;
   values[3] = values[0] + values[5];
   values[9] = values[5] / 10;
   --values[2];
   
   
   
   for ( index =0; index <10; ++index)
   
   printf("values[%i] = %i\n", index, values[index]);
   

   return 0;



}


but i corious why program in post 1 have result like that
can you explain
thank you
Smiley

 30 
 on: February 16, 2015, 10:28:02 PM 
Started by slackie - Last post by slackie
hello everbody, i am newbie so please help me

i have a little problem about array in program 7.1 on book programming in c third edition

this is the program

// working with array

#include <stdio.h>

int main (void)
{

   int values[10];
   int index;

   values[0] = 197;
   values[2] = -100;
   values[5] = 350;
   values[3] = values[0] + values[5];
   values[9] = values[5] / 10;
   --values[2];

   
   for ( index =0; index <10; ++index)
   printf("values[%i] = %i\n", index, values[index]);
   
   return 0;

}


the result  should be like this

values[0] = 197
values[1] = 0
values[2] = -101
values[3] = 547
values[4] = 0
values[5] = 350
values[6] = 0
values[7] = 0
values[8] = 0
values[9] = 35


but my result is different

when is use mingw the result is

values[0] = 197
values[1] = 3
values[2] = -101
values[3] = 547
values[4] = 4218880
values[5] = 350
values[6] = 4202350
values[7] = 4202256
values[8] = 0
values[9] = 35

when i use cygwin the result is

values[0] = 197
values[1] = 1629192174
values[2] = -101
values[3] = 547
values[4] = 1629192174
values[5] = 350
values[6] = 1627419952
values[7] = 47
values[8] = 2280836
values[9] = 35

and  in cygwin when i ask program to give number again the result diffrent with before
why my result is different?
i have been  give value to index like this
for ( index =0; index <10; ++index)
index = 0; ( in for)
why the program like i don't use array
it is like i use ++index in values[index]
can you explain that sir
may be i  wrong about purpose the program

thank you Smiley

Pages: 1 2 [3] 4 5 ... 10


Login with username, password and session length

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 (c) 2009 classroomM.com. All rights reserved.