Amazon.com Widgets Recent Posts
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 18, 2014, 05:02:08 PM
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: April 11, 2014, 08:36:34 AM 
Started by hierzo - Last post by BrianLawson
It isn't xCode, it is the OS. This is part of sandboxing, keeping an app's memory access to only its own memory. Otherwise, you could write a program that could read all of the memory of the computer that it was running on and send that to you for analysis to search for passwords and other personal info.

 22 
 on: April 11, 2014, 08:25:14 AM 
Started by hierzo - Last post by hierzo
Hi Brian,
I agree with you. My gut feeling is that xCode prevents this, maybe however just because my knowledge of xCode is still very small.
I'll try to build two app's I can run from the shell and see what happens.

 23 
 on: April 11, 2014, 06:45:54 AM 
Started by hierzo - Last post by BrianLawson
I don't believe that iOS (or OS X for that matter) allows one program to access the memory of another program. You would have to use some kind of messaging system to pass data between the two programs.

 24 
 on: April 11, 2014, 04:59:56 AM 
Started by hierzo - Last post by hierzo
Hi,  

I've two different projects running in xCode: one you could call ScoreBoard and the other Assistant. I'm not working on a game or anything these names are to help you give an idea what i'm trying to do.

In ScoreBoard I create a variable int teamA, I set a value, retrieve the &teamA location and stop the program using a breakpoint to read the location of the variable.

In Assistant I create two variables: int *setTeamA , int point;
I set   point=0; but what I'm interested in is &point.
I use a breakpoint to retrieve its value in order to calculate the difference to &teamA from the ScoreBoard program. The difference I use to set 'setTeamA' variable.

so setTeamA = &point + difference  (so now &teamA ==setTeamA) (all is checked)
*setTeamA should set the value of teamA in Scoreboard.  *setTeamA=1;
now I continue the Assistant program where I expect the Assistant program to set the value of teamA in the ScoreBoard program.

In Scoreboard I continue the program to check the value of teamA. And as you can imagine.. it does not work.. teamA is still on it old value.

My knowledge on bits addressing and xCode obviously lacks. Can anyone comment on what I'm trying to accomplish, why it doesn't work and how it should be done?





 25 
 on: April 10, 2014, 06:22:25 PM 
Started by 星如雨 - Last post by 星如雨
// Ex 7-5
// Complex.h
#import <Foundation/Foundation.h>

@interface Complex : NSObject

@property int realNum, imageNum;
- (void) setRealNum: (int) n setimageNum: (int) d;
- (Complex *) add: (Complex *)f;
- (void) print;

@end

// Complex.m

#import "Complex.h"

@implementation Complex

@synthesize realNum, imageNum;

- (void) setRealNum:(int)n setimageNum:(int)d
{
    realNum = n;
    imageNum = d;
}
- (void) print
{
    NSLog(@"X+Y=%i+%ii", realNum, imageNum);
}
- (Complex *) add:(Complex *)f
{
    Complex *result = [[Complex alloc]init];
    result.realNum = realNum+f.realNum;
    result.imageNum = imageNum+f.imageNum;
    return result;
}

@end

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
   
    @autoreleasepool {
       
        // insert code here...
        Complex *test1 = [[Complex alloc]init];
        Complex *test2 = [[Complex alloc]init];
        Complex *testResult;
       
        [test1 setRealNum:78 setimageNum:72];
        [test2 setRealNum:20 setimageNum:30];
       
        testResult = [test1 add:test2];
        [testResult print];
       
    }
    return 0;
}



 26 
 on: April 10, 2014, 05:43:29 PM 
Started by MlonyTheGeek - Last post by TheTopBloke
I'm posting mine here because this might help you out. my variable is tries, your equivalent is times. Note where I utilized it after initializing it.

Code: (Objective-C)
#import <Foundation/Foundation.h>

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

    @autoreleasepool
    {

        int n, number, triangularNumber, counter, tries;
       
        NSLog(@"How many triangular numbers would you like to create?");
        scanf("%i", &tries);
       
        for (counter=1; counter<=tries; ++counter)
        {
            NSLog(@"What triangular number do you want?");
            scanf("%i",&number);
           
            triangularNumber=0;
           
            for (n=1; n<=number; ++n)
            {
                triangularNumber+=n;
            }
            NSLog(@"Triangular number %i is %i", number, triangularNumber);
        }
       
    }
    return 0;
}


 27 
 on: April 10, 2014, 02:02:14 PM 
Started by TheTopBloke - Last post by TheTopBloke
Thanks. I was wondering why that was the case. Should have recognized it was the int. I'll try it out.

 28 
 on: April 10, 2014, 12:46:36 PM 
Started by TheTopBloke - Last post by BrianLawson
Try making your factorial variable an unsigned long int. Notice that the factorials for 17 & 18 are negative and factorial 19 is less than factorial 16. That happened because your program has exceeded the size of a number that an int can hold. By declaring the variable to be unsigned, it won't show as negative when the high order bit turns on and by making it a long you get more room for the values you are computing.

 29 
 on: April 10, 2014, 11:40:37 AM 
Started by TheTopBloke - Last post by TheTopBloke
Just in case you were wondering. I have the left column justified left, and right column justified right.

Code: (Objective-C)
#import <Foundation/Foundation.h>

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

    @autoreleasepool
    {
       
        int n, j;
        int factorial=1;
       
        for (n=0; n<20; n++)
        {
            for (j=1; j<=n; j++)
            {
                factorial *=j;
            }
           
            NSLog(@"Factor of %-3i is %10i", n, factorial);
            factorial=1;
        }
       
    }
    return 0;
}

OUTPUT

2014-04-10 11:39:21.903 Ch5Ex4[15904:303] Factor of 0   is          1
2014-04-10 11:39:21.905 Ch5Ex4[15904:303] Factor of 1   is          1
2014-04-10 11:39:21.905 Ch5Ex4[15904:303] Factor of 2   is          2
2014-04-10 11:39:21.906 Ch5Ex4[15904:303] Factor of 3   is          6
2014-04-10 11:39:21.906 Ch5Ex4[15904:303] Factor of 4   is         24
2014-04-10 11:39:21.907 Ch5Ex4[15904:303] Factor of 5   is        120
2014-04-10 11:39:21.907 Ch5Ex4[15904:303] Factor of 6   is        720
2014-04-10 11:39:21.908 Ch5Ex4[15904:303] Factor of 7   is       5040
2014-04-10 11:39:21.908 Ch5Ex4[15904:303] Factor of 8   is      40320
2014-04-10 11:39:21.909 Ch5Ex4[15904:303] Factor of 9   is     362880
2014-04-10 11:39:21.910 Ch5Ex4[15904:303] Factor of 10  is    3628800
2014-04-10 11:39:21.910 Ch5Ex4[15904:303] Factor of 11  is   39916800
2014-04-10 11:39:21.910 Ch5Ex4[15904:303] Factor of 12  is  479001600
2014-04-10 11:39:21.911 Ch5Ex4[15904:303] Factor of 13  is 1932053504
2014-04-10 11:39:21.911 Ch5Ex4[15904:303] Factor of 14  is 1278945280
2014-04-10 11:39:21.912 Ch5Ex4[15904:303] Factor of 15  is 2004310016
2014-04-10 11:39:21.912 Ch5Ex4[15904:303] Factor of 16  is 2004189184
2014-04-10 11:39:21.913 Ch5Ex4[15904:303] Factor of 17  is -288522240
2014-04-10 11:39:21.913 Ch5Ex4[15904:303] Factor of 18  is -898433024
2014-04-10 11:39:21.914 Ch5Ex4[15904:303] Factor of 19  is  109641728
Program ended with exit code: -1

 30 
 on: April 10, 2014, 05:54:19 AM 
Started by MlonyTheGeek - Last post by BrianLawson
n(n+1) tells the compiler that you have a function named n and you want to pass it the argument n+1. Implicit multiplication is not allowed.

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.