objective-c

Detect touch *anywhere on the screen* in cocos2d?

I'm really sorry, I realize there have been several questions asked about cocos2d touch detection (including this answer which helped me a bunch), but I just can't get any of them to work. I would have commented on the answer I linked instead of asking my own question, but i don't have enough rep to leave comments. All I want to do i...

Scaling not as smooth in 3.0 as in 2.x

I have a CATiledLayer backed UIView that is added to UIScrollView and it is returned as view to be scaled in response to -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView delegate method. Now the problem is that scaling on a scale falling between the 2x steps provided by CATiledLayer (like for example 1.333) results in v...

How can I make an NSDictionary contain a selector as one of its values?

This code is in a UITableViewController subclass viewDidLoad method. The UITableViewController subclass contains a test method. It crashes without throwing an exception. id dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys: @"some text", @"text", @selector(test), @"selector", nil] ...

Better way to move NSView bounds with player?

Currently writing a roguelike to learn more about Objective-C/Cocoa. I'm really enjoying it so far and I've learned tons. This code moves the origin of the view's bounds, so that it follows the player as he moves. The code works perfect, I was just asking if there was a better way than using four for's. I've also seen in some cases th...

How do I get a selector from its name?

I have an NSString containing the name of a selector I would like to call with performSelector. How can I get a reference to the selector from the string? ...

Change text in GKPeerPickerController

Is it possible to change the default text (something like "looking for other iPhones and iPod touches") in the GameKit's GKPeerPickerController? I've seen solutions that are completely custom but I was wondering if i can avoid that hassle and just change the default text. ...

How do you get the int and modulo (mod) of division with an NSDecimalNumber

I am confused by NSDecimalNumber and its "behaviors". I have an NSDecimalNumber that represents a dollar value, say $37.50. I'd like to find out how many times say 5.0 goes into that number and then know what's left over. I can get the straight division and get 7.50 but I want 7 mod 2.50. I could convert to an integer but need to save th...

How to pass username and password to a web service from within an iPhone app?

Hi All, Have a look to this code snippet:- CommonService objcommonService; NetworkCredential myCredentials = new NetworkCredential("144552", "F@mous123456"); objcommonService.Credentials = myCredentials; This is a C#.net code. In this snippet "objcommonService " is a object of the webservice "CommonService". This webservice pre auth...

Altering the style of an NSSearchField.

I am wondering how I would change the look of an NSSearchField, I am pretty sure it would mean sub-classing NSSearchField, but the bit I don't know how to do is code it to make it the way I want it to look. Below you can see the way I want it to look and how it looks currently. How would I make it look like this (on the left) by usin...

Help with Sending/ Receiving UDP packets - C Sockets

Ok, if you look at some of my previous questions, I've been working on getting a simple connection up and running with C sockets (I'm still fairly new to the whole networking aspect of an program, but everyone has to start somewhere, right?). I've included the code below that I have so far and when I execute it, I get no errors, but at t...

Core Data Fetched Properties to rank connectivity between Objects

I want to rank how strongly connected instances of Entity A are to other instances or Entity A are in my graph.I only need to do this for the n most recently viewed entities. I describe relations between two instances of Entity A by means of another Entity B. This is because I need to describe each relationship. I was considering using ...

What is "Attempt to lookup host entry for bad IP address" error?

Hi All, Check this error and please help me. 2009-07-24 15:58:34.209 LBS[2636] Host 'staging.common.virtualearth.net' not found using 'gethostbyname()' - perhaps the hostname is wrong or networking is not set up on your machine 2009-07-24 15:58:34.209 LBS[2636] Attempt to lookup host entry for bad IP address (staging.common.virtualearth...

?examine a response while webView:shouldStartLoadWithRequest:naviagiontType... waits?

iPhone/objC I'm really stuck here and I could use some help, please. Let me first explain some things: I have an UIWebView which loads an url. once the user clicks a link - (BOOL)webView:shouldStartLoadWithRequest: navigationType: gets a message (according to the protocol). Inside this method I can decide if the url should be loaded ...

UITableViewCell not moving up and down

Hello all does anyone know if it's possible or that the UITableviewcells have a function or attribute that allows them to not move up or down( when you scroll with the mouse) Just as if it where a couple of buttons glued to the screen. ...

UITableView pushViewController On Selecting a Row

Hi all, I'm building an iPhone app with a UITableView. On selecting a row, I'd like a UIWebView to be pushed in loading a specific URL. I currently have: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSDictionary * story = [stories objectAtIndex:[indexPath row]]; NSString * storyLink =...

Add buttons under a tableview

Hello, I'm trying to create a view programmatically. The result that i want to have is a scroll view with a tableview inside. And under this table view i want to add some buttons I don't know exactly how to do that i tried this but it doesn't work : - (void)loadView { [super loadView]; tableView = [[UITableView alloc] initWit...

Why am I getting an invalid NSString from SQLite for my UILabel?

I have a view with a UILabel and a UITableView. I'm using this code to get a string from a database: -(void)getOneQuestion:(int)flashcardId categoryID:(int)categoryId { flashCardText=[[NSString alloc] init]; flashCardAnswer=[[NSString alloc] init]; NSString *martialStr=[NSString stringWithFormat:@"%d", flashcardId]; ...

Returning other objects on init

I've read in many places that you should always initialize Objective-C objects like so: - (id) init { if (self = [super init]) { .... } return self; } Because the super's init method may return a separate object from the current self. Now I'm trying to do something like this, and I'm not sure if I have it right, v...

@properties question on iPhone development

From what I've read, @properties and @synthesize are used to tell the compiler to to generate getters and setters for various properties of our class. So I am confused when I see the source code of an Apple example, the GKTank, that uses only one class for the whole game (apart from the app delegate) and still most of the attributes of ...

Creating multiple class instances on the fly

My question involves a simple game that 2-4 people can play. This is a game that is played on one iphone/ipod touch so no networking is required. When the game is started, the user will select the number of players that will play. For each player I need to create and instance of the Player class. My question is how do I code so that on...