2018-10-21         Phoenix

How to debug an objective-c program (pbcopy supplied by Apple) with gdb?

I need to debug an objective-c program.When setting a breakpoint on main() function , I've got:Reading symbols from /usr/bin/pbcopy...done.(gdb) break mainFunction "main" not defined.Invoking "start" from reply the same error.I suspect the way of doing things is different on max os x ?What is the equivalent with objective c program?BTW how to break on exit() function?Edit: I try breaking on -[NSApplication run] as proposed by Lyndsey(gdb) file pbcopyReading symbols for shared libraries ........ doneReading symbols from /usr/bin/pbcopy...done.(gdb) break -[NSApplication run]...

 objective-c                     2 answers                     53 view
 2018-10-22         Maxine

Reading live output from shell script and updating progress bar

I have a shell script logging a list of numbers (1, 2, and so forth, one per line) to a log file. I need my ObjC app to read the log file every X seconds and then update my progress bar accordingly based on the last number logged in the log file.What's the best way to do this? Why not use NSFileHandle's readInBackgroundAndNotify instead? This way, your code only runs when something really does happen in the file. [XXX]You can create an instance of NSTimer and have it, every X seconds, call another method that's responsible for reading the file and updating your progre...

 objective-c                     2 answers                     89 view
 2018-10-22         Maurice

How to change the width of UITabBarItem?

How to change the width of UITabBarItem?I have an item with the title, that is wider than default item width. How can I fix it? I just searched through the documentation and saw no method for adjusting the UITabBarItem's width. A possible solution would be to place a view within the tab bar controller to load a custom UITabBarItem, that is the proper width. [XXX]Solution for iOS7 and greater versions:A new property has been introduced for UITabBar: itemWidth. Set the itemWidth to a positive value to be used as the width for tab bar items when they are positioned as ...

 objective-c                     4 answers                     5 view
 2018-10-22         Jesse

How to find the direction of the line in Cocoa?

Consider a line AB in Cartesian coordinates system. The length of the line is d. What I need:I want to draw an arrow in the point B, to represent the direction of the line.What I tried:I found a point C, which is placed in the line AB, before some x points of B. Then I tried to find points (P & Q) with respect to the line CB in 90 degrees. But it does not work for me.Refer this image:Rather than doing this complex steps, is there any other way to find the direction of the line to draw the correct arrow in right direction?Please remember the line may lie in any direction...

 objective-c                     1 answers                     99 view
 2018-10-22         Ingemar

Compare the value of a variable at intervals

Hey I have a problem comparing the value of a CGPoint (struct with two ints: x and y) with another at certain time intervals.One is called location and has the value of where the cursor is. Every half a second or so, I want to see if it changed. How do I do this? The language is Objective-C (so C++/C stuff should work) What are you trying to do with this? Would it make more sense to use Key Value Observing to observe when one or both values change? [XXX]Take a look at the NSTimer documentation. It does what you want. [XXX]As noted in the CGGeometry docs, Apple pro...

 objective-c                     3 answers                     23 view
 2018-10-22         Norma

Calling sync POST with parameters in Xcode

I found many samples of code to sending a POST request using NSURL & dispatch_sync but none that sends parameters like AFHTTPRequestOperationManager does. Would someone supply a reference or a code snippet?I need to send text, numbers and images. If doing network requests, you should always perform them asynchronously. If you want to block the UI while awaiting a response from the server, don't make the request synchronous, but rather keep it asynchronous, but present the UI that indicates that the user must wait for the response (e.g. a UIActivityIndicatorView or th...

 objective-c                     1 answers                     71 view
 2018-10-22         Rex

Spotlight search based OSX app

I've been on the iOS side alot, and was thinking about a mac app.There isnt much interface to it. The app is a reference app, with data thats searchable. there are about 300 items. I want the app to:Be searchable in the Spotlight. Typing in spotlight should bring about that item(s) from the appSearching an Image and hovering over it with the mouse will bring about a small display window for that image or textfile, showing its contents. I wanted something similar, though the app would Not be a textfile based app, but I'd like the native OS to show a sample window.a native wi...

 objective-c                     1 answers                     94 view
 2018-10-22         Jeremy

Core Data NSFetchRequest problem

I am trying to develop a test Core Data app so i can use it in my main app. But im having problems fetching stored data.I have 1 Entity "User" with 2 attributes: name (String) & email (String)I can successfully populate my store file with data... here is the code im using below.Any help would be greatly appreciated.NSManagedObjectContext *managedObjectContext;NSError *error;NSString *basePath = @"/Users/Jamie/Desktop";NSURL *storePath = [NSURL fileURLWithPath: [basePath stringByAppendingPathComponent:@"datastore.xml"]];NSLog(@"Data Store path: %@", storePath);NSPersiste...

 objective-c                     1 answers                     49 view
 2018-10-22         Olive

Using NSManagedObject manually - something wrong with the NSManagedContext I get?

I'm new to Cocoa programming, and decided for my first project to create a small application to monitor and remember certain battery stats for my laptop. (I have it plugged in most of the time, and apple recommend you discharge it now and again, so why not try to make a small program to help you remember to do this? :))Anyway, I have a standard Objective-C project, with a DataModel file.It contains an Entity, BatteryEvent, with properties, charge and event.I then have PowerListener.m (and .h).PowerListener.m is implemented as follows: @implementation PowerListenervoid my...

 objective-c                     1 answers                     52 view
 2018-10-22         Nancy

uiview rotation keeping 1 coordinate constant

Good Day!i want to ask that if i want to bring a uiview in front on another view, but i want to bring it by keeping its 1 points constant so that it looks like that only 1 (top) portion moved down. i put my uiview on 90 degrees but i could not figure out the way to bring it horizontal. here is code for uiviewclView.frame = CGRectMake(0,100,258,171);clView.transform = CGAffineTransformIdentity;clView.transform = CGAffineTransformMakeRotation(degreesToRadians(90));[self.view addSubview:clView];Now it puts my view to 90 degrees but i could not bring it down with animation keep...

 objective-c                     1 answers                     65 view
 2018-10-22         Bartholomew

UIView touchesbegan doesn't respond during animation

I have a draggable class that inherits UIImageView. The drag works fine when the view is not animating. But when animating it won't respond to touches. Once the animation is completed the touch works again. But I need it to pause the animation on touches and resume when touch ends.I spent the whole day researching it but couldn't figure out the reason.Here is my animation code.[UIView animateWithDuration:5.0f delay:0 options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction) animations:^{ self.center = CGPointMake(160,240); self.transfor...

 objective-c                     1 answers                     70 view
 2018-10-22         Xavier

Is there a way of sharing a Core Data store between processes?

What am I trying to do?A UI process that reads data from a Core Data store on disk. It wouldn't need to edit the data, just read and display the data.A command line process that writes to the same data store as accessed by the UI. Why?So that the command line process can be running all the time but the user can quit the UI process and forget about the app until they need to look at the data it's captured.What would be the simplest and most reliable way of achieving this?What Have I Tried?I've read up on sharing a data store between threads and implemented this once before, ...

 objective-c                     4 answers                     79 view
 2018-10-22         Christine

Instance variable naming conventions in Cocoa

This question is about variable naming style in objective c and cocoa. I just want to stress that I'm not looking for a "right" answer, just good ideas.I've read through Apple and Google's objective c style guides and I'm not really happy with either of them. Apple's guide doesn't have any real style recommendations regarding instance variables vs local variables. In fact, the Cocoa library itself seems perfectly happy having function parameters of the exact same name as instance variables. That makes me cringe personally.Googles guide specifies that instance variables ...

 objective-c                     5 answers                     80 view
 2018-10-22         Mandel

How to unhide the hidden application in mac os programmatically?

I want to unhide the hidden applications in mac os . For hiding I am using this [ [ NSWorkspace sharedWorkspace ] hideOtherApplications ]; There's several ways to unhide all hidden apps — here are a couple of them:NSWorkspace:NSMutableArray *arr = [[NSMutableArray alloc] init];for (NSRunningApplication *app in [[NSWorkspace sharedWorkspace] runningApplications]) { [app unhide];}...or...NSApplication:- (void) unhideAllApplications:(id)sender{ [NSApp unhideAllApplications:sender];}and call with something like:[self unhideAllApplications:nil]; [XXX]

 objective-c                     1 answers                     18 view
 2018-10-22         Antonia

Kill process after launching with AuthorizationExecuteWithPrivileges

If I launched a shell script using AuthorizationExecuteWithPrivileges what would be the easiest way to kill the script and any other processes that it spawned.Thanks It's running as root, so you can't kill it from a regular-user process. You're going to have to ask it nicely to exit on its own. [XXX]Apple has sample code that uses stdout to pass the PID back to the caller. [XXX]Use the communications pipe that AuthorizationExecuteWithPrivileges() returns by reference in its last argument, FILE **communicationPipe, to send a message to the child process that asks ...

 objective-c                     3 answers                     64 view
 2018-10-22         Barry

Fade Animation (UIViewAnimation)

At this point, I am working with simple view switching, and now I'm working with animation while switching views in xcode. However, my knowledge is not extensive on the topic, and I have spent about an hour researching this question before posting, so I have tried,All I want to do is simply fade to the next view. I don't know if there is an animation for it, but what I am doing is making the app fade to black on a certain orientation for practice. However, if there is a better animation that you could suggest, please do so. Thanks!-Jake If this is the crux of your questi...

 objective-c                     1 answers                     36 view

Page 1 of 652  |  Show More Pages:  Top Prev Next Last