Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Coding Releases > Coding Snippets
You last visited: Today at 00:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Mal ein wenig Objective-C

Discussion on Mal ein wenig Objective-C within the Coding Snippets forum part of the Coding Releases category.

Reply
 
Old   #1

 
snow's Avatar
 
elite*gold: 724
Join Date: Mar 2011
Posts: 10,479
Received Thanks: 3,318
Mal ein wenig Objective-C

Mal ein wenig Objective-C, alle Samples benötigen zwingend das ASIHTTPRequest-Framework.

elitepvpers.com Login:

Code:
- (void)loginWithUsername:(NSString *)username Password:(NSString *)password
{
   NSString *loginURL = @"http://www.elitepvpers.com/forum/login.php?do=login";
   NSString *requestBodyString = [NSString stringWithFormat:@"vb_login_username=%@&vb_login_password=%@&cookieuser=1&s=&securitytoken=guest&do=login&vb_login_md5password=&vb_login_md5password_utf=", username, password];
    
   NSURL *url = [NSURL URLWithString:loginURL];
   __weak ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setPostBody:[NSMutableData dataWithData:[requestBodyString dataUsingEncoding:NSUTF8StringEncoding]]];
   [request setShouldRedirect:NO];
   [request addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%d", [requestBodyString length]]];
   [request addRequestHeader:@"Content-Type"   value:@"application/x-www-form-urlencoded"];
    
   [request setCompletionBlock:^{
       
   		if ([[request responseString] rangeOfString:@"Thank you for logging in"].location != NSNotFound || [[request responseString] rangeOfString:@"Danke für deine Anmeldung"].location != NSNotFound) {
        
         //success
   		} else {
         //error
   		}	       
    }];
    
    [request setFailedBlock:^{
        //network error?
    }];
    
    [request startAsynchronous];
}
Treasure erstellen (davor einloggen, Cookies werden durch ASIHTTP gesichert):

Code:
- (void)createTreasureWithTitle:(NSString *)title text:(NSString *)text price:(NSString *)price
{
    
    NSString *postBody = [NSString stringWithFormat:@"title=%@&content=%@&cost=%@&createtreasure=Submit", title, text, price];
    NSString *url = [NSString stringWithFormat:@"http://www.elitepvpers.com/theblackmarket/treasures/"];
    
    ASIHTTPRequest *_request = [[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:url]];
    __weak ASIHTTPRequest *request = _request;
    
    [request addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%d", [postBody length]]];
    [request addRequestHeader:@"Content-Type" value:@"application/x-www-form-urlencoded"];
    
    [request setPostBody:[NSMutableData dataWithData:[postBody dataUsingEncoding:NSUTF8StringEncoding]]];
    
    [request setShouldRedirect:NO];
    
    [request setCompletionBlock:^{
            
        if ([[request responseString] rangeOfString:@"<div>Deine Treasure wurde erfolgreich erstellt.</div>"].location != NSNotFound || [[request responseString] rangeOfString:@"<div>Your treasure has been successfully created.</div>"].location != NSNotFound) {

			//success            
        } else if ([[request responseString] rangeOfString:@"<li>You've to wait 15 seconds before you can create your next treasure.</li>"].location != NSNotFound) {

			// wait 15 seconds, hm
        } else {
        
        	// error    
        }
    }];
    
    [request setFailedBlock:^{

		//network error?        
    }];
    
    [request startAsynchronous];
}
snow is offline  
Thanks
4 Users
Reply


Similar Threads Similar Threads
Suche erfahrenen Objective-C Coder für iOS App Hilfe
11/24/2013 - Coders Trading - 1 Replies
Hey, ich suche jemanden der mir bei einem kleinen Problem in meiner iOS App in Xcode behilflich sein kann. Eine angebrachte Vergütung in Form von e*Gold oder PSC ist natürlich sicher! Für denjenigen sollte die Aufgabe in wenigen Minuten zu bewältigen sein, da ich selbst leider noch nicht sehr Erfahren im Bereich iOS-Development bin. Bitte meldet euch per PN! Danke
Suche Objective-C(++) Developer.
07/13/2011 - General Coding - 0 Replies
Hallo! Ich habe folgendes vor: Für Mac OS X gibt es keine IDE um ordentlich WoW Addons zu programmieren. Diesen XML-Müll per Hand zu schreiben ist einfach nervig und meiner Meinung nach ist der XML Teil für Frames in WoW richtig dumm. Warum nicht einfach Alles in lua... Naja auf jeden Fall spiele ich schon lange mit dem Gedanken sowas mal zu machen. Aber alleine ist mir das Warten zu viel Arbeit. Außerdem kann man sich für Updates mehr Zeit lassen wenn man nicht alle Features selbst...
Objective C
03/25/2010 - General Coding - 3 Replies
gibt es eine IDE für Objective C für einem Windows-Rechner (wie XCode auf Mac)? oder kann man nur auf einem Mac mit Objective C programmieren? Danke im Voraus!
Objective C, Iphone Development
10/22/2009 - General Coding - 11 Replies
Hi, ich wollte einfach mal nachfragen, ob hier auch interessierte Objective C oder gar Iphone Developer anwesend sind, bzw. ob es lohnt Diskussionen zu diesen Themen zu starten oder nicht.



All times are GMT +1. The time now is 00:42.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.