cocoa

Count number of newlines in a file

Hi, What is the smallest code I can use to count the number of occurrences of the newline character in a file with objective-c / cocoa touch? Thanks! ...

C: fscanf and character/string size

Hello. I am parsing a text (css) file using fscanf. The basic goal is simple; I want to pull out anything that matches this pattern: @import "some/file/somewhere.css"; So I'm using fscanf, telling it to read and discard everything up to a '@' character and then store everything until it reaches a ';' character. Here's the function that...

CoreData/SQLite fastest way to determine if a field doesn't end with a particular string

I'm using CoreData backed by SQLite and I'm trying to find the fastest way to exclude rows where the field AirDate ends with -00-00 I've noticed that [NSPredicate predicateWithFormat:@"NOT AirDate CONTAINS %@", @"-00-00"] is much faster than [NSPredicate predicateWithFormat:@"NOT AirDate LIKE %@", @"*-00-00"] Are there any other o...

Change Window Button's Control Tint

I'd like to override the default system control tint for my app to be always NSGraphiteControlTint. The following code doesn't seem to work though. Any suggestions? NSButton *button = [window standardWindowButton:NSWindowCloseButton]; [[button cell] setControlTint:NSGraphiteControlTint]; Regards, Erik ...

Trying to get bytes and append using NSMutableData for a video through Asset Library gives memory full error

Hi, I’m trying to upload a video of size 100MB through Asset Library. But when i try to use "- (NSUInteger)getBytes:(uint8_t )buffer fromOffset:(long long)offset length:(NSUInteger)length error:(NSError *)error” of ALAssetRepresentation i get memory full error. I also need to put the data in buffer to NSData. How can i achieve that? ...

Anything like layout manager in Java for iOS?

Guys, I am a newbee for iOS. I need to create dynamic layout since the GUI will be generated according to the data. I checked the UIView references, it seems the standard way to add subview is like: CGRect rect = CGRectMake(0, 0, width, height); UILabel *label = [[UILabel alloc] initWithFrame: rect]; [someView addSubView: label]; But...

IBPlugin: Adding additional objects on drag from IB Library

I have a list view class that just like NSCollectionView requires an additional prototype item and a prototype view to be of any use. When dropping an NSCollectionView from the library in Interface Builder those two helper items are automatically created. However I couldn't find a single official Apple document dealing with this use case...

Getting the album artwork, song name, album name and artist name from an audio file.

How can I get album artwork, song name, album name and artist name from an audio file? I need to display this without the use of iTunes. Thanks. ...

RegexKit Category problem

I'm having some trouble using the RegexKit.framework. I've properly integrated it into my project and I want to use the NSString category methods to get an array of matches from a string. Though I have imported the the framework Xcode keeps complaining that "NSString may not respond to '-stringByMatching:'". Do I miss something when work...

NSString to camel case

Hi all, I am trying to figure out how to take a given NSString and convert it to camel case. I have seen lots of code samples out there for going back and forth between underscores_ and camel-case, but I am dealing with strings that are capitalized. So if I had the string: 12345 SAMPLE STREET #12 or 789 N HASKELL STREET, how would I ...

How to know which NSTableView opened a Contextual Menu?

Hi!, I have 5 NSTableView's instances that have the same contextual menu. When I get the message that the menu has been clicked I need to know which table sent it. I've checked the NSMenu documentation but I don't seem to find a way to check which of the tables opened the menu.. I'm thinking of subclassing NSTableView and send a message...

Should NSWindowController always be the superclass of a window controller?

When reading Apple's Cocoa tutorial, the window controller is just a regular class and while understand that this is perfectly fine I suppose, wouldn't it be better to subclass NSWindowController? If I get this right, NSWindowController is a convenience class which already has a lot of the functionality required by a window controller i...

Why doesn't this code produce the correct output?

Given a string and a number, this function will produce all possible combinations of n letters from that string. i.e. If I pass "abcd" and 3, then I should get the following output: abc abd acd bcd This is the code - (void)viewDidLoad { [super viewDidLoad]; [self expand_combinations:@"abcd" arg2:@"" arg3:3]; } -(void) expan...

External framework (iMedia) + Garbage collector leaks memory?

In case the answer is obvious, please don't be hard on me, i'm still new to Cocoa. I recompiled the iMedia framework to make use of garbage collection, which it officially supports, according to their issue tracker (tracker entry). iMedia parses iTunes' XML library file and loads everything into an NSDictionary (i call it "monster dicti...

How to change this so that it returns arrays

The following code works perfectly and shows the correct output: - (void)viewDidLoad { [super viewDidLoad]; [self expand_combinations:@"abcd" arg2:@"" arg3:3]; } -(void) expand_combinations: (NSString *) remaining_string arg2:(NSString *)s arg3:(int) remain_depth { if(remain_depth==0) { printf("%s\n",[s UTF8Stri...

Borderless NSButton turns gray when clicked.

I am making a little application with three NSButtons with an image set. These buttons have no border nor background. However, when I click a button it turns into a gray rectangle. How can I fix this? Thanks. ...

Understanding the Inheritance hierarchy in OOP

When Looking at the inheritance hierarchy trees in OOP when two objects are side by side in the diagram what is their relationship to each other? For example: NSWindow and NSView both inherit from NSResponder, so are they siblings? How do their respective methods relate? ...

Creating an OS X Address Book Plugin

I'm taking my first steps toward learning to write desktop code for the Mac and, thinking it would be a baby step, I decided to write an Address Book plugin to "fix" something that's annoyed me for a long time. Embarrassingly, I can't even get the boilerplate plugin to work the way I think it's supposed to work. My understanding from th...

CHCSVParser in the main thread

Hello all, This is a follow-up to a previous post regarding the CHCSVParser from Dave DeLong. In short, I am using the CHCSVParser to work with an extremely large CSV file and parse the lines into Core Data entities (on an iPhone). I've got the parser hooked up and working, and am now trying to display a progress indicator to the user...

NSTextView Subclass - A4 Paper Look

Hello, I am thinking about modifying my NSTextView to look like an A4 sheet. So basically a line drawn around the textContainer, but I don't know how this could be done... Just in case no one understands what I mean, I've attached a screenshot :P http://web.me.com/david.schiefer/a4.png Thanks :) ...