Amazon.com Widgets Recent Posts
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 21, 2015, 01:14:41 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: March 27, 2015, 12:04:25 PM 
Started by magickirbyz - Last post by Koma
There is my code:

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


int main(int argc, const char * argv[])
{
    @autoreleasepool {
       
        int a,b;
        bool y;
       
        NSLog(@"Type two numebrs:");
        scanf("%i%i",&a,&b);
       
        y=a%b?YES:NO;
       
        if (a==0||b==0)
            NSLog(@"You Can not type 0!!!");
        else
            if (y==NO)
            NSLog(@"%i is evenly divisible by %i.",a,b);
         else
            NSLog(@"%i is not evenly divisible by %i.", a,b);
                 
                      }
    return 0;
}

 22 
 on: March 27, 2015, 06:40:09 AM 
Started by ramzee - Last post by ramzee
Thank you for your quick response and hope the administrators will check this message.

Regards,
Ramya

 23 
 on: March 27, 2015, 02:02:35 AM 
Started by ramzee - Last post by Waiting
Hello Ramya,

Only the administrators have the power to add forum sections, moderators can only move threads around.

I'm not sure when the admin users last visited the forum, so i'm unsure how long your request may take.


 24 
 on: March 27, 2015, 12:52:16 AM 
Started by jonr - Last post by ramzee
I started recently with the 6th edition and I have the same feeling that we need a new thread with 6th edition and have it categorised by chapters. I just posted my request on this forum. I hope the moderator of this forum is still active  and take this suggestion actively. As this forum is very helpful for all doing self study of Objective C language.

 25 
 on: March 27, 2015, 12:47:58 AM 
Started by ramzee - Last post by ramzee
Dear Moderator and the fellow members of the forum,

I was going through the forum and I see there are two boards for 4th and 5th editions. Now that the 6th edition has come up I suggest we have a new thread for the 6th edition. Besides I have observed that 4th edition thread is organised chapter wise which makes it very easy to search for topics required. Is there a way to organise the 5th edition as well or have a new thread for 6th edition and have it categorised by chapters?? That will save a lot of time searching through the posts.

Thank you for this forum. This is very helpful for selfstudy and I hope my suggestion would make it easy to access the topics.

Regards
Ramya

 26 
 on: March 23, 2015, 04:12:05 PM 
Started by bertobettencourt - Last post by objective-cMEX
#import <Foundation/Foundation.h>

I think this works fine, if you find a way to improve it, please feedback, regards!!!!

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        int limit, x=4, y=5, z=10;
        
#define MAX3(a,b,c) ( ((a > b) && (a > c)) ? (a) : ((b > a) && (b > c)) ? (b) : (c) )
        
        limit = MAX3 (x, y, z);
        NSLog(@" The Maximum from %i, %i & %i is: %i",x, y, z, limit );
    }
    return 0;
}

 27 
 on: March 14, 2015, 04:26:40 AM 
Started by Sp1DeR - Last post by Sp1DeR
Good day. I only learn Obj-c. I'm sending a login and password, get back to html page, how do I open the page after the request and closed loginWindowController? is the request itself :
Code: (Objective-C)
#import "LoginWindowController.h"
#import "AFNetworking.h"
#import "MainWindowController.h"

@interface LoginWindowController ()

@end

@implementation LoginWindowController

- (void)windowDidLoad {
    [super windowDidLoad];

}

- (IBAction)loginButton:(id)sender{

    NSString *myLogin = usernameTextField.stringValue;
    NSString *myPassword = passwordTextField.stringValue;
    NSString *myFlash = flashpasswordTextField.stringValue;
    NSString *myNid = @"123456";
    NSString *urlString = @"http://neverlands.ru/game.php";
    NSString *ua = @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36";

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    AFHTTPRequestSerializer * requestSerializer = [AFHTTPRequestSerializer serializer];
    [requestSerializer setValue:ua forHTTPHeaderField:@"User-Agent"];
    manager.requestSerializer = requestSerializer;
    AFHTTPResponseSerializer * responseSerializer = [AFHTTPResponseSerializer serializer];
    manager.responseSerializer = responseSerializer;
    NSDictionary *parameters = @{@"player_nick": myLogin, @"player_password": myPassword};
    [manager POST:urlString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //Условия после запроса 1
        if ([operation.responseString rangeOfString:@"NeverLands: Земли, которых нет... - Второй пароль"].location == NSNotFound) {
            NSLog(@"Неверный логин или пароль");
        } else {
            NSDictionary *parameters = @{@"flcheck": myFlash, @"nid": myNid};
            [manager POST:urlString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
                //Условия после запроса 2
                if ([operation.responseString rangeOfString:@"NeverLands: Земли, которых нет... - бесплатная браузерная онлайн игра в стиле фэнтези"].location == NSNotFound) {
                    NSLog(@"Неверный флеш пароль");
                } else {
                    mainWindowController = [[MainWindowController alloc] initWithWindowNibName:@"MainWindow"];
                    [mainWindowController showWindow:self];
                    [mainWindowController addWebView:[NSURL URLWithString:urlString]];
                    NSLog(@"Авторизация произведена");
                }
            } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                NSLog(@"Error: %@", error);
            }];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];
}

@end
what to write here that would have opened the current session?

  
Code: (Objective-C)
mainWindowController = [[MainWindowController alloc] initWithWindowNibName:@"MainWindow"];
                [mainWindowController showWindow:self];
                [mainWindowController addWebView:[NSURL URLWithString:HERE]];
I tried [mainWindowController addWebView:[NSURL URLWithString:urlString]]; But open page with a new session and writes that the username and password is not entered.

 28 
 on: March 13, 2015, 05:12:20 PM 
Started by jonr - Last post by jonr
In chapter 15 we were shown to display an NSNumber object we could do the following:
Code: (Objective-C)
NSNumber *intNumber = @100;      // We were also shown this earlier as a way to assign values; an alternative to using the creation and init class method
NSLog (@"%@",  intNumber);       // This will display the value of the NSNumber object as an int

Why then for an NSNumber that is a char, we can't use '%@' to display a char; to get the proper result we have to use the retrieval instance method?
The following won't give the desired result.  What's displayed (as you would expect) is the int equivalent of the character.
Code: (Objective-C)
NSNumber *charNumber = @'T';      
NSLog (@"%@",  charNumber);

Instead, to display the value properly, in the NSLog call we have to use the retrieval instance method instead of just using the variable name as in the first example: 
NSLog (@"%c",  [charNumber charValue]);
And as you would expect, to go along with that, the %c format character is needed.  But the primary question is why the retrieval method is needed here while it wasn't required in the first example with the int.  I suppose that the issue of whether '%@' will work or not is secondary to that and is a by product of the primary issue

I'm fully aware of the relationship between ints and chars.  I'm just curious as to the default behavior here.

 29 
 on: March 05, 2015, 12:12:38 AM 
Started by skochan - Last post by sunder
Dear Kochan Sir,your books come highly recommended by my mentor.I loved your "Programming in C".I finished it and I was looking for a book on c++ .Hopefully your recommendations on page 503 paid off when I happened to visit the miscellaneous Heading where a handful of recommendations were out there for various languages.It worked out pretty well for me.
Please recommend me a book on "Algorithm designs" and "JAVA".I have no prior knowledge on it and am willing to study it right from the scratch. Please recommend me a book for the same.
Thanks a lot . :)You are my Role Model. Grin

 30 
 on: March 03, 2015, 08:14:21 AM 
Started by joezing - Last post by joezing
The following code represents a simple (blunt force?) approach to finding overlapping rectangles.  I would appreciate comments.
In the intersect method the code uses a structure to hold the x,y coordiantes of the 3 triangles (Base, Second and Overlap).
First the 'doesOverlap'  routine is called to determine if overlap is possible.  If not then the 'intersect' method exits.
Next a series of 'if tests' is executed to determine the position of the each point of the 'second' rectangle with respect to the 'base' rectangle.
From the 'if tests' a set of coordinates for the overlap rectangle is developed.

I have tested the code with a variety of different rectangles, both overlapping and non-overlapping. I believe that the code works

//
//  main.m
//  Chapter 8 exercise 7

#import <Foundation/Foundation.h>
#import "Rectangle.h"
#import "xyPoint.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       
        Rectangle *myRect = [[Rectangle alloc] init];
        XYPoint *myPoint = [[XYPoint alloc] init];
        Rectangle *overlap = [[Rectangle alloc] init];
//set the program up to permit testing of different rectangles, both overlapping and non-ovelapping
        //myRect is the rectangle to which the second rectangle will be compared
       
        [myPoint setX: 6 andY: 1];
       
        [myRect setWidth: 5 andHeight: 4];
       
        [myRect setOrigin: myPoint];
       
        //allocate, initialize and set the values for the second rectangle
       
        Rectangle *secondRect = [[Rectangle alloc] init];
        [myPoint setX: 1 andY: 1];
       
        [secondRect setWidth: 5 andHeight: 4];
        [secondRect setOrigin: myPoint];
       
        //invoke the 'intersect' method
        overlap = [myRect intersect:secondRect];
       
        if ( overlap.origin.x == 0)
            NSLog(@" No overlap found");
//the following code is the solution for exercise 8.8 and is commented out.
       
//        else
//            [myRect draw: (Rectangle *) overlap];
       
}
return 0;
}


//
//  Rectangle.m
//  Chapter 8 exercize ex 7
//
//

#import "Rectangle.h"


@implementation Rectangle

{
    XYPoint *origin;
}


@synthesize width, height;

-(BOOL) doesOverlap: (struct rectanglePTS) r1 andr2:(struct rectanglePTS) r2
{
   
    if (r2.lr.x < r1.ll.x )
        return false;
    if (r2.ll.x > r1.lr.x)
        return false;
    if  (r2.ll.y > r1.ul.y)
         return false;
    if (r2.ul.y < r1.ll.y)
        return false;
   
    return true;
}

-(Rectangle *) intersect: (Rectangle *) r
{
    //the 'overlap' rectangle describes the overlap triangle, if any
    Rectangle *overlap = [[Rectangle alloc] init];
   
    XYPoint *myPoint = [[XYPoint alloc] init];
   
   
    //'rectanglePTS is a Class-level structure designed to hold the 4 points of a rectangle.  this simplifies comparing and storing coordinates
    struct rectanglePTS r1;
    struct rectanglePTS r2;
    struct rectanglePTS r3;
   
    //structure r1 is loaded with the x,y coordinates for the 'base' rectangle, the one to whice the other rectangle will be compared.
    r1.ll.x = origin.x;
    r1.ll.y = origin.y;
    r1.ul.x = origin.x;
    r1.ul.y = origin.y + self.height;
    r1.ur.x = origin.x + self.width;
    r1.ur.y = origin.y + self.height;
    r1.lr.x = origin.x + self.width;
    r1.lr.y = origin.y;
   
    //structure r2 is loaded with the x,y coordinates for the rectangle to be compared against the base rectangle
    r2.ll.x = r.origin.x;
    r2.ll.y = r.origin.y;
    r2.ul.x = r.origin.x;
    r2.ul.y = r.origin.y + r.height;
    r2.ur.x = r.origin.x + r.width;
    r2.ur.y = r.origin.y + r.height;
    r2.lr.x = r.origin.x + r.width;
    r2.lr.y = r.origin.y;
   
    //check to see if there is the possibility of rectangle overlap.  If not, return a rectangle object with 0 coordinates.
   
    if ( ! [self doesOverlap: r1 andr2: r2])
        return overlap;
   
    //if there is an overlap determine the overlap coordinates via a series of if tests.  Structure r3 is being loaded with the overlapping rectangle coordinates
   
    if (  r2.ll.x <= r1.ll.x) {
        r3.ll.x = r1.ll.x;
        r3.ul.x = r1.ul.x;
    }
    else {
        r3.ll.x = r2.ll.x;
        r3.ul.x = r2.ul.x;
    }
   
    if (  r2.ll.y <= r1.ll.y) {
        r3.ll.y = r1.ll.y;
        r3.lr.y = r1.lr.y;
    }
    else {
        r3.ll.y = r2.ll.y;
        r3.lr.y = r2.lr.y;
    }
   
    if (r2.ul.y >= r1.ul.y) {
        r3.ul.y = r1.ul.y;
        r3.ur.y = r1.ul.y;
    }
    else {
        r3.ul.y = r2.ul.y;
        r3.ur.y = r2.ur.y;
    }
   
    if (r2.ur.x >= r1.ur.x) {
        r3.ur.x = r1.ur.x;
        r3.lr.x = r1.lr.x;
    }
    else {
        r3.ur.x = r2.ur.x;
        r3.lr.x = r2.lr.x;
    }
   
    //allocate XYPoint object in preparation to load points into 'overlap' rectangle
    [myPoint setX: r3.ll.x andY: r3.ll.y ];
    [overlap setOrigin: myPoint];
    overlap.height = r3.ul.y - r3.ll.y;
    overlap.width = r3.lr.x - r3.ll.x;
   
    return overlap;
}
 

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.