objective-c

NSScrollView frame and flipped documentView

Hi, I have problems with NSScrollView, It is not displayed the way I want. Yes I know there is a lot of post about it around the web, I need to override the isFlipped, in order to make it return YES, in my NSView subclass. Ok, it's done, so now, my scrollView scroll from top to bottom, and not in the reverse way, as it was before overr...

NSString - max 1 decimal of a float

Hi everyone, I would like to use a float in a NSString. I used the stringWithFormat and a %f to integrate my float into the NSString. The problem is that I would like to display only one decimal (%.1f) but when there is no decimals I don't want to display a '.0' . How can I do that? Thanks ...

Is there any way to control settings inside iphone app rather than settings outside the app?

Is there any way to control settings inside iphone app rather than settings outside the app? and I could not find what kind of item I will add to plist in settings.bundle in order to change font type for example; Times New Roman to Calibri I searched other references that people gave me 1 day ago but I could not find a point that make...

What is the '^' in Objective-C

What does the '^' mean in the code below? @implementation AppController - (IBAction) loadComposition:(id)sender { void (^handler)(NSInteger); NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setAllowedFileTypes:[NSArray arrayWithObjects: @"qtz", nil]]; handler = ^(NSInteger result) { if (result == NSFileH...

Trying to understand NavigationController retain count for ViewControllers on its stack

I have an UITableViewController as the rootViewController for my navigatorController. When I press a table cell I do the following: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MessageHistory *msg = (MessageHistory *)[[self fetchedResultsController]objectAtIndexPath:indexPath]; Conversa...

Initializing a readonly property

I was trying to create a property which is readonly. I wanted to initialize with a value from the class creating an instance of this class, e.g. @property (retain,readonly) NSString *firstName; And I tried to initialize it like this: -(id)initWithName:(NSString *)n{ self.firstName = n; } Once I did this, the compiler reported an er...

how to create a black rounded-corners window in cocoa

Hi, How to create a rounded corners black window in cocoa? Is it standard and can be created by IB? Can somebody provide an example? Thanks in advance ...

How would I write the following applescript in Obj-C AppScript? ASTranslate was of no help =(

The translation tool isn't able to translate this working code. I copied it out of a working script. set pathToTemp to (POSIX path of ((path to desktop) as string)) -- change jpg to pict tell application "Image Events" try launch set albumArt to open file (pathToTemp & "albumart.jpg") save albumArt...

Cannot find protocol declaration in Xcode

Hi.. I've experienced something today while I'm building my app. I've declared a protocol in my MyObject1 and add delegate property on it. I've assign MyObject2 as a Delegate of the MyObject1. I've added it in this way as usual @interface MyObject2 : UIViewController <DelegateOfObject1> But the Xcode says that my the protocol declara...

NSTableView binding problem

I have only just started with XCode (v3.2.2) and Interface Builder and have run into a problem. Here is what I have done: I have made a class to be the datasource of a NSTableView: @interface TimeObjectsDS : NSControl { IBOutlet NSTableView * idTableView; NSMutableArray * timeObjects; } @property (assign) NSMutableArray * timeObje...

Global Variable problem

Hi, I am new in iphone.I use a flag variable to play songs in avAudio player all songs are properly handeled with flag variable.we have two tabs in tab bar , i want that if any song playing then on other tab song info show.If we use that flag variable then i syncronize song info with song.But i can't access the value of flag on song in...

Usage of autorelease pools for fetch method

Hi, I'm a little bit confused regarding the autorelease pools when programming for the iPhone. I've read a lot and the oppionions seem to me from "Do-NOT-use" to "No problem to use". My specific problem is, I would like to have a class which encapsulates the SQLite3 Access, so I have for example the following method: -(User*)fetchUser...

Navigation between more than two views without changing content in textfield

Hi, I've created 3 views in each i've one textfield in which i enter something and move from first to second and then to third and back to first but i want the same first page to be displayed with same content in textfield before navigating i.e. the meaning is that i want to swap between 3 views instead of creating views as how we remove...

Smart way to search an array of arrays

I have an array of arrays with objects and now want to get all objects for a certain date (which is an object property). what's the best way to query it? ...

Backspace not working when implementing shouldChangeCharactersInRange method - iPhone Dev

Problem... I have a string of allowable characters "0123456789." How do I also allow the backspace from the keyboard... when I implement the code from below... the backspace key no longer works... How can I fix this? * (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *...

List of already used objective-c Prefixes

I'm looking to choose a namespace for a library I'm writing and I'd like to avoid conflicts with other namespaces. Does anyone know of a website that lists all of the class prefixes in use? ...

Is the scope of what Xcode's "Build and Analyze" will catch as a leak supposed to be this limited?

It doesn't care about this: NSString* leaker() { return [[NSString alloc] init]; } I thought it would have been smart enough to check if any code paths could call that function without releasing its return value (I wouldn't normally code this way, I'm just testing the analyzer). It reports this as a leak: NSString* leaker() { NSSt...

How can I use OCMock to verify that a method is never called?

At my day job I've been spoiled with Mockito's never() verification, which can confirm that a mock method is never called. Is there some way to accomplish the same thing using Objective-C and OCMock? I've been using the code below, which works but it feels like a hack. I'm hoping there's a better way... - (void)testSomeMethodIsNeverCal...

C++ from SpeakHere in iPhone app

Hi guys, I've made a template app where I've grabbed the recording part of the SpeakHere example and removed the file handling part, but I'm struggeling to get the C++ part of the app working right. As soon as it enters the C++ class, it gets syntax errors. If I don't import the header files from C++ (and then of course don't use the co...

parsing simple html for iphone

I have a very simple html page to parse. The html page will remain simple always. as simple as this <html> <head><title>title</title></head> <body>some data here</body> </html> I have fetched the html content of such an html page and have it in an NSString. I want to get what ever data is there in the body of the html page. Please ...