I have an NSDictionary where each key points to an array. I later want to merge all of the values into one array. Is there a way to use the API to do something more efficient than say:
NSArray *anArray = [someDictionary allValues];
NSArray *newArray = [NSMutableArray array];
start outter loop on anArray
start inner loop on objects in...
I recently found myself writing a piece of code that executed a Core Data fetch, then allocated two mutable arrays with the initial capacity being equal to the number of results returned from the fetch:
// Have some existing context, request, and error objects
NSArray *results = [context executeFetchRequest:request error:
NSMutableArra...
Hello,
i feel like having memory leak in the next code
while([outData length] + ptr[currentPacket].mDataByteSize < inBytesToGet && currentPacket < packetsCount)
{
NSLog(@" ++> %d", [aData retainCount]) ;
NSInteger sO = ptr[currentPacket].mStartOffset ;
NSInteger dS = ptr[currentPacket].mDataByteSize ;
NSLog(@" get: cP: %d...
This isn't a style question. Its more about the proper use of the language itself. I'm am fairly new to programming and I'm totally new to Objective-C and Cocoa but after reading about the language and looking through some sample code some usage patterns continue to pop up that do not make sense to me. Or rather they seem non optimal in ...
I'm having some trouble getting CGColorGetConstantColor() to work on the iPhone. Apple's documentation claims you can pass any of the "Constant Colors" without linking to what the Constant Colors actually are, so I assumed you can simply use those documented for OS X:
CGColorRef blackColor = CGColorGetConstantColor(kCGColorBlack);
Thi...
Does anyone have a quick way to make a UISlider that looks like the ones in the iPod app (think scrubber/volume control). Basically I need something that looks exactly like an MPVolumeView, but doesn't control sound. Failing that, does anyone have the assets to make one (the knob/track).
...
Hi,
For my app I need to use the Carbon file manager API to get the size of a folder (NSEnumerator is slow, and using NSTask with a shell command is even worse). I've imported the Carbon framework, and I'm using this method to get the size of a folder:
http://www.cocoabuilder.com/archive/message/cocoa/2005/5/20/136503
It uses an FSRef...
I would like to access a couple of different Mac OS X applications from preferably Ruby, but I would settle for PHP. The applications are Elgato's turbo.264 and Apple's iTunes. Both have Applescript Libraries defined that would allow me to do what I want to do from Applescript, but I don't want to do this in Applescript. If I can't do th...
I'd like to change the value of a parameter at runtime and curious how this works in Obj-C.
I have a loop where value of 'n' is 0 increasing by 1 with each loop. How does one increment the passed parameter by 1 as n moves.
UIViewSubclass *uiViewSubclass = [[UIViewSubclass alloc] initWithValue:([value integerValue])
...
UIImage has a read-only property CGImage. I have to read its pixels to a memory block and edit them and then make a new UIImage to replace the old one. I want to know if there is a way bypass the read-only property and edit those pixels directly.
Thanks.
Thanks all. I have found a way to do it. Write a class with those method:
-(vo...
I want to use the NSStatusBar object from my Java application using JNI. I know there's some existing libraries out there but I've tried them and they don't have the correct drop down menu.
I'm starting from the "Java JNI Application" template in XCode and I simply put
NSString *str=@"";
to see if it could compile but this produces ...
We are creating an application which records the surrounding sound and take necessary action if the sound crosses specified Decibel.
In order to achieve the application objective we are using following method from AudioQueueObject.h
- (void) getAudioLevels: (Float32 *) levels peakLevels: (Float32 *) peakLevels {
UInt32 propertySize...
Hi,
I'm using very tricky fighting methods :) to make a string like 'Fi?le*/ Name' safe for using as a file name like 'File_Name'.
I'm sure there is a cocoa way to convert it. And I'm sure the best place to ask is here :)
Thank you!
...
How can I get the list of class methods for a particular Class? I've tried using the class_copyMethodList function declared in <objc/runtime.h>, but that's only giving me instance methods. I've also found a function that gives me a Method for a class method, but only if I have the selector to the method first (class_getClassMethod).
A...
If I want to create a entity in Core Data that has attributes with values that should be localizable I'm wondering how the most efficient way would look like?
As a example let's assume the following structure:
Book
name (localizable)
description (localizable)
author
An localized book entry would look like this:
name: ...
What setDateFormat option for NSDateFormatter do I use to get a month-day's ordinal suffix?
e.g. the snippet below currently produces:
3:11 PM Saturday August 15
What must I change to get:
3:11 PM Saturday August 15**th**
NSDate *date = [NSDate date];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[date...
In C#, I use XML/XSLT transformation to isolate markup from data. What's the equivalent in Objective C?
...
I need to do some date + time stuff that is not covered well by NSDate on the iPhone. I wonder if there is a library that has more sophisticated functionality regarding dates and time on a international level.
What I want to do is advanced date + time mathemathics. I need to:
convert between different calendar types (Gregorian <> Jewi...
I am creating an NSDictionary with -initWithObjectsAndKeys:.
For every object I provide to that dictionary I call a selfmade method -createFooBarObject, which will create and return the object.
Now the problem: The create method by definition should not release the object because it must return it, and the caller is responsible for rel...
According to Apple and numerous examples I've seen, there is no problem using KVO/KVC to observer yourself. Also according to those same sources, it's not a problem setting this up by using addObserver:forKeypath:options:context: in an object's init method, a la:
- (id)init
{
self = [super init];
if (self) {
[self addObserv...