I have parsed some data from webpage content and stored it as an NSString. In that string there is a unicode character (\u0097). How can i remove or replace this and avoid all unicode characters?
I tried using this line but it hasn't worked:
[webpagecontent stringByReplacingOccurrencesOfString:@"\\u0097" withString:@" "];
Can anyone ...
- (void)mouseDragged:(NSEvent *)theEvent {
NSSize dynamicImageSize;
dynamicImageSize = [[self image] size];
NSSize contentSize = [(NSScrollView*)[[self superview] superview] contentSize];
if(dynamicImageSize.height > contentSize.height || dynamicImageSize.width > contentSize.width)
{
float x = startOrigin.x - ...
How do I achieve the following conversion from double to a string:
1.4324 => "1.43"
9.4000 => "9.4"
43.000 => "43"
ie I want to round to to decimal places but dont want any trailing zeros, ie i dont want
9.4 => "9.40" (wrong)
43.000 => "43.00" (wrong)
So this code which I have now doesn't work as it displays excess twos:
[NSString...
I have an array an a timer that adds a new object to my array every 5 seconds but am running into a slight issue. I have a code that is called repeatably which moves the objects in my array but for some reason the previous object that spawns will stop moving when a new object is spawned into my array. How do I make it so every single obj...
What is the quickest way to jump to a particular symbol/selector/class in Xcode? (I'm looking for keyboard shortcuts preferably).
Right now, I know two ways of doing this:
“Open Quickly” > Click on the Symbols dropdown menu at the top of the editor > Select the selector to jump to it.
Click on “Project Symbols” in the “Groups and File...
Ok, I have some C# code that looks like this and I was wondering what other developers would recommend if I am trying to put this into Objective-C.
List<List<string>> meta_data
I'm planning on using NSMutableArray but how to exactly get that two-dimensional array figured out is my problem, since there is no such thing as a multidimens...
Still learning Objective-C / iPhone SDK here. I think I know why this wasn't working but I just wanted to confirm.
In awakeFromNib, if I use [[NSMutableDictionary alloc] initWithObjects:...] it actually allocates (iPhone) system memory with this NSMutableDictionary data, but when I use [NSMutableDictionary dictionaryWithObjects:...] it ...
I'd really appreciate some advice around testing for errors using OCMock.
Method Under Test
It grabs a process using an instance of the AppScriptController class.
@implementation ProcessGrabber
-(void)grabProcess {
NSError *error = nil;
NSString *processName = [appScriptController processName:ProcessRef
...
I'm new to programming for the iPhone and i'm wondering: how extensible are the various controls? Let's take the button as an example:
can i change the background graphic?
can i make it grow larger when i press on it?
can i change the font?
can i use a custom font?
can i use a button graphic in place of text?
...
I have a very simple Mac Cocoa app that just has a Web View that loads an HTML file with some CSS and JavaScript. I have hooked up the app delegate to this method:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSString* filePath = [[NSBundle mainBundle] pathForResource: @"index" ofType: @"html"];
NSURL *ur...
I want to be able to determine if the number of bytes in an instance of NSMutableData is equal to zero. How would I do this?
...
On Linux under X11 and using GTK+ you have something called "Main Loop". Once you start the main loop you have a timer that runs in the main thread of the application. You can set that timer to a callback function and you have a very nice application-wide timer.
This is sample code for that:
GMainLoop *loop;
if(!loop_running)
{
...
I want to write an application which may have multiple documents in a single window via a tabbed interface. Should I avoid the NSDocument architecture (the Cocoa Document-based Application template)? As far as I can tell, it supports only one or more window per document but not vice versa.
I have been wrestling with this question for ...
I need to get the mouse position on the screen on a Mac using Xcode. I have some code that supposedly does that but i always returns x and y as 0:
void queryPointer()
{
NSPoint mouseLoc;
mouseLoc = [NSEvent mouseLocation]; //get current mouse position
NSLog(@"Mouse location:");
NSLog(@"x = %d", mouseLoc.x);
NSLog...
I am working on porting a Java codebase to Cocoa/Objective-C for use on desktop Mac OS X. The Java code has lots and lots of methods with checked exceptions like:
double asNumber() throws FooException {
...
}
What's the best way to represent these in Objective-C? Exceptions or error out-parameters?
- (CGFloat)asNumber {
... ...
I have a bunch of texts and images (taken from the content tag of a RSS feed item) that I want to display in my app. I've managed to extract them from the entire content tag with some regular expressions. But the thing is, in order for the texts to appear before all the images are loaded, I need to preload all the images, and even more, ...
I have an application which needs to be able to write to Any User/Current host preference files (which requires admin privileges per Preferences Utilities Reference) and also to enable/disable a launchd agent via its plist (writable only by root).
I'm using SFAuthorizationView to require users to authenticate as an admin before alterin...
I'm slowly teaching myself cocoa for the iPhone(through the Stanford Class on iTunes U) and I've just gone through the part on memory management, and I wanted to hopefully get some confirmation that the assumptions I'm making on how memory is handled and how [release] and [autorelease] work. Since memory management is a really basic and...
I have an application composed of a GUI and 3 launchd daemon launched command-line executables.
I'm planning to put the executables for the launchd daemons inside the .app bundle for the GUI.
These apps utilize 2 (both fairly small) frameworks which I have created.
Is it a better idea to put these frameworks in /Library/Frameworks (an...
I am writing some objective-C code and i can't figure out why this does not work:
buttonRect = CGRectMake(0,0,100.0,100.0);//error:incompatible types in assignment
CGRect newFrame = CGRectInset(buttonRect, -0.2, -0.2);//error:incompatible type for argument 1 of CGRectInset
button.frame = newFrame;
buttonRect is a CGRect defined as an ...