cocoa

NSURLConnection and the corresponding device type

For the iPad, iPhone, iTouch app that talk to remote web service by making NSURLConnection calls, is there a way for the remote service to tell what kind of device that the call is made from? Basically, how I can know the device type of the device on which my app is running? ...

I get the warning "Format not a string literal and no format arguments" at NSLog -- how can I correct this in the code supplied? TIA!

Hello, I get the warning "Format not a string literal and no format arguments" on the NSLog call in the following block: - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog([NSString stringWithFormat:@"%d", buttonIndex]); } I have read in another post here that this error message indica...

Cocoa structs and NSMutableArray

I have an NSMutableArray that I'm trying to store and access some structs. How do I do this? 'addObject' gives me an error saying "Incompatible type for argument 1 of addObject". Here is an example ('in' is a NSFileHandle, 'array' is the NSMutableArray): //Write points for(int i=0; i<5; i++) { struct Point p; buff = [in readD...

Issue with CGEventTapCreate() call.

Hi All, I'm trying to register for global key events using this code : void function() { CFMachPortRef keyUpEventTap = CGEventTapCreate(kCGHIDEventTap,kCGHeadInsertEventTap,kCGEventTapOptionListenOnly,CGEventMaskBit(kCGEventKeyUp),&keyUpCallback,NULL); CFRunLoopSourceRef keyUpRunLoopSourceRef = CFMachPortCreateRunLoopSource(NULL, ke...

Using ScriptingBridge framework for communicating with Entourage

Hi, The motivation for my question is the following doc, which describes how mail.app could be integrated using ScriptingBridge: http://developer.apple.com/mac/library/samplecode/SBSendEmail/Introduction/Intro.html I tried to apply a similar technique with Entourage as well but could not get any results so far. I understand that using...

how to sorting NStable data in cocoa application?

I have implementing one cocoa application.In which i have used NStableview.In which i have displayed data from the database.Now i want to sorting data in nstableview when user click on tablecolom.I have used sortDescriptorsDidChange (delegate) method for sorting but this method is not called.can u help me for this problem. ...

How to insert a WebView into a cocoa app?

I'm rather new with the whole OSX programming, I wanted to stick a WebView into an empty app. Apparently it isn't as simple as sticking a WebView on a window in interface builder and creating an outlet. IBOutlet WebView *webView; It gives me a expected specifier-qualifier-list before 'WebView' and when I don't use an outlet, it te...

How to resize a UISwitch?

I have made a custom UISwitch (from this post). But the problem is, my custom texts are a bit long. Is there any way to resize the switch? [I tried setBounds, did not work] Edit: Here is the code I used: @interface CustomUISwitch : UISwitch - (void) setLeftLabelText: (NSString *) labelText; - (void) setRightLabelText: (NSString *)...

Sending an image in a faceless email

I am trying to send a faceless email (sending an email without showing the interface), using the code below. I also want to attach an image to this email. Is this possible? - (void) sendEmailTo:(NSString *)toStr withSubject:(NSString *)subjectStr withBody:(NSString *)bodyStr { NSString *emailString=[[NSString alloc] initWithFormat...

NSURLConnection, NSURLRequest, untrusted cert and user authentication

Morning Everyone, I've been attempting to write an application that does some GETs from a remote Web Service that requires authentication. My main problem is that the majority of these remote servers (and there are a lot of them) don't have valid certificates. I've got code to accept the invalid certificate and code to respond to the ch...

Newbie: UINavigationController is pulling me back from further learning :(

I have created a window-based application and my problem is I am unable to create UINavigationController on the go. InFact I don't know how to do that. My AppDelegeate - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after application launch [window addSubview:logInVi...

Enable access for assistive device programmatically

Hi All, I want to enable Access for assistive devices in System Preferences programmatically. But Problem is that my application is not running as root user and i do not want my application to be as root user and also should not ask for any authentication in between. I want to tap all keyboard events globally. I am using CGEventTap...

NSOperation Causing Crash when Passed to Delegate

For an iPhone app, I'm using a NSOperationQueue to limit access to the SQLite database to one query at a time. I created a subclass of NSOperation and in the main function I have the following: - (void)main { // ... other code here ... if( [_delegate respondsToSelector:@selector(queryCompleted:)] ) { [_delegate ...

UIWebView memory management

Hello, I have a problem with memory management. I am developing an application that makes heavy use of UIWebView. This app generates dynamically lots of UIWebViews while loading content from my server. Some of these UIWebViews are quite large and have a lot of pictures. If I use instruments to detect leaks, I do not detect any. However...

Create object from NSString of class name in Objective-C

I was wondering if i could create a object of some class if i have the name of the class in a NSString. I know this is possible in other languages like ActionScript, C# and PHP... Something like this: NSString *className = @"AwesomeViewController"; UIViewController *object = [[className alloc] initWithNibName:className bundle:nil]; ...

Is it possible to create a UINavigationController within a ModalPopup?

Hi I have a modalViewController that I am popping up using [self presentModalViewController:myController animated:YES]; I have an event occurring within myController which I would like to result in another controller being pushed onto the navigation stack ON TOP OF myController (which again has been presented modally). How can I ...

Determing if an NSOpenGLView has a valid context (Cocoa OSX)

I am trying to check that my NSOpenGLView has a valid context but it seems that a call to openGLContext will not help me figure this out. openGLContext seems to always returns a an NsOpenGlContext (it returns the current context if the view has one and if not it makes a context and returns that). Is there another method I could use ins...

How can I truncate an NSString to a set length?

I searched, but surprisingly couldn't find an answer. I have a long NSString that I want to shorten. I want the maximum length to be around 20 characters. I read somewhere that the best solution is to use substringWithRange. Is this the best way to truncate a string? NSRange stringRange = {0,20}; NSString *myString = @"This is a strin...

Cocoa app not launching on build & go but launching manually

I have quite the interesting problem. Yesterday my program worked perfectly, but now today I'm getting exc_bad_access when I hit build and go, but if I launch the app from the build folder it launches perfectly and there seems to be nothing wrong. The last bunch of lines from the debugger are: #0 0xffff07c2 in __memcpy #1 0x969f7961...

How can I get the domain name for a user logged into a Mac via Active Directory

In my Cocoa app how can I get the current user's domain when they're logged in via Active Directory? I need to determine two things: If the current user is logged on to an Active Directory domain (only need to handle Active Directory). If 1, the domain of the user. I've found references to Directory Services and the Open Directory P...