When we have an object who has a property that's generated based on other properties, usually we implement the +keyPathsForValuesAffecting{PropertyName} class method.
What I'm trying to do is basically the same thing for a property on my NSManagedObject, but traversing a relationship.
My model is simple; I have two Entities, App and Ve...
I am new to objective-c and am having trouble figuring out a way to store points for multiple players in my game. I have 4 characters in my game that are all objects from the same class. 1 is controlled by the user and the other 3 are controlled by the computer. Each level in my game consists of 3 races. I need a way to keep track of eac...
It seems that it's not possible to play an alert sound
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
while the AudioQueue is being used to record audio. Is that correct? Maybe I'm doing something wrong. Is there a way to do this other than pausing the recording?
TIA.
...
I've added a text shadow to cells in my UITableView to give them an etched look:
cell.textLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.000];
cell.textLabel.shadowColor = [UIColor whiteColor];
cell.textLabel.shadowOffset = CGSizeMake(0, 1);
Since the shadow color is actually white, when a row gets selected and becomes blue, th...
I'm writing my first iPhone application and I'm having trouble switching views. I have 2 views and a reference to each in the AppDelegate (an instance of UIApplicationDelegate). I create instances of both in the applicationDidFinishLaunching and immediately show the first view. This works fine.
The problem is the reference to the o...
Let's say I have a code like this...
- (id) init {
...
self.myImage1 = [NSImage imageNamed:@"some_image_name"]; // setter retains
...
}
- (void) setStatusItemImage
{
[self.statusItem setImage:self.myImage1];
}
I also want to animate the status item so I created 6 variants of the "updating" status item icon and loop it...
Working on a game in Objective-C/Cocoa for OS X, and I finished the prototype as much as it's worth being finished. It's a mess of code, being my first game, but everything works. I've been reading up on the best way to put things together, and MVC seems to make the most sense, but I'm a bit confused.
Where does it start? With the cont...
I am looking for a raster graphics framework for Mac OS X. Specifically, I want some kind of view that I can manipulate (at least conceptually) like a matrix of pixels. My program will generate the pixel data programmatically.
QuickDraw fits that description nicely, but is deprecated. As far as I can tell, there is nothing equivalent in...
I am currently using xcode and I find it's lack of tabs quite disturbing.
I currently use command-shift-d to search through all the files, or ctrl-1 to open the history of files that were recently opened.
It works but I find it less effective than just tabbing through the few files i am currently working on.
Is there any way, third pa...
I have an designated initializer with optional arguments (similar to the following code), and I want to create an autorelease method by calling it. Is there any way to do this?
@interface MyObject : NSObject
- (id)initWithArgs:(id)firstArg, ...;
+ (id)objectWithArgs:(id)firstArg, ...;
@end
@implementation MyObject
- (id)initWithArgs...
Hi,
I'm relatively new to Cocoa/ObjC. Could someone please help me change my code to use asynchronous network calls? Currently it looks like this (fictional example):
// Networker.m
-(AttackResult*)attack:(Charactor*)target {
// prepare attack information to be sent to server
ServerData *data = ...;
id resultData = [self se...
When initializing an NSMutableArray array with object, Why put nil at the end?
e.g.
NSMutableArray *fruits = [[NSMutableArray alloc] initWithObjects:apple,
watemelon,
nil];
In Xcode, when using auto comple...
I am assigning protocols in a couple classes that follow an inheritance tree. Like so:
first class
@protocol LevelOne
- (void) functionA
@end
@interface BaseClass : NSObject <LevelOne> {
}
second class
@protocol LevelTwo <LevelOne>
- (void) functionB
@end
@interface SubClass : BaseClass <LevelTwo> {
}
Later I am assigning the c...
If we write the following code:
ExplorerAppDelegate * appDelegate = (ExplorerAppDelegate *)[[UIApplication sharedApplication] delegate];
This makes a reference to the original delegate pointer, but:
Does it increase the reference count?
Do we have to explicitly call as [ExplorerAppDelegate retain] right after, or not at all?
What...
Hi, I'm working on an iPhone game written in Objective C (which I'm new to). The problem is
that the views which are used to draw the sprites on screen are semi transparent. I have set
the alpha to 1.0 and the opacity to True. I have also used NSLog to confirm that the views' alphas are 1.0. I was using [self.view insertSubview:myView]; ...
Question 1)
I have a navigation based application where clicking on an entry opens a second view with the details of that entry.
It's working now with the following code
[self.navigationController pushViewController:descriptionController animated:YES];
[self.descriptionController.textView setText:[s description]];
self.descriptionC...
I have two view controllers (viewControllerA and viewControllerB) with their own views. When the user touches a button in the view of viewControllerA, I am able to load the view of the viewControllerB.
However, I don't know how to invoke a method in viewControllerB's class!
...
I need to create a dictionary/hashmap where the
Keys are enums
Values are some subclass of NSObject
NSDictionary won't work here (enums don't conform to NSCopying).
I could perhaps use a CFDictionaryRef here, but I'd like to know if is there any other way to achieve this.
...
I need to use a website with quite a bit of content in my App via UIWebView.
When I scroll the page in Mobile Safari everythings scrolls smoothly. Even if I scroll fast - the grey squared background appears but is rendered properly after a few moments (less then 0.5 seconds).
The same page in UIWebView scrolls jerkily if scrolled fast ...
my application shows this error
asm CPSqliteConnectionStatementForSQL 0x30897lb3:10
and it stopped at this breakpoint in debugger
0x308971cb <+0024> mov 0x8(%edi),%eax
does someone know about it?
...