Re: UpdateSystemActivity(OverallAct) to prevent sleep in Lion...

2011-08-30 Thread Jean-Daniel Dupas
Le 29 août 2011 à 22:29, R a écrit :

> I'm using UpdateSystemActivity(OverallAct) successfully to prevent
> sleep in Snow Leopard.  Can anyone confirm that this works with Lion?
> 
> thanks

Probably, but you should use the IOPMAssertion API introduced in 10.5 instead.

See IOPMAssertionCreateWithName reference for details.

Note: On 10.5, this API does not prevent the screen saver to start, so if you 
need to support this feature on Leopard, you may have to continue to use 
UpdateSystemActivity on this OS version.

-- Jean-Daniel




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Possible causes of "attempted layout while textStorage is editing"?

2011-08-30 Thread Gideon King
I am receiving occasional reports from customers who are seeing this error:

_fillLayoutHoleForChar acterRange:desiredNumberOfLines:isSoft: *** attempted 
layout while textStorage is editing. It is not valid to cause the layoutManager 
to do layout while the textStorage is editing (ie the textStorage has been sent 
a beginEditing message without a matching endEditing.)

0 CoreFoundation 0x7fff822847b4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x7fff883dbf03 objc_exception_throw + 45
2 CoreFoundation 0x7fff822845d7 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x7fff82284564 +[NSException raise:format:] + 148
4 AppKit 0x7fff8192ce00 -[NSLayoutManager(NSPrivate) 
_fillLayoutHoleForCharacterRange:desiredNumberOfLines:isSoft:] + 643
5 AppKit 0x7fff8192c9b0 -[NSLayoutManager(NSPrivate) 
_fillLayoutHoleAtIndex:desiredNumberOfLines:] + 211
6 AppKit 0x7fff8192b62f 
_NSFastFillAllLayoutHolesUpToEndOfContainerForGlyphIndex + 679
7 AppKit 0x7fff8192b1a5 -[NSLayoutManager 
textContainerForGlyphAtIndex:effectiveRange:] + 243
8 AppKit 0x7fff81840c12 -[NSLayoutManager glyphRangeForTextContainer:] + 286

The offending line of code is:

[layoutManager glyphRangeForTextContainer:[[layoutManager textContainers] 
firstObject]];

(with the intention of causing layout so I can get the usedRectForTextContainer)

...but during this method, the only thing I have done is set the text container 
size to a user defined width (never less than 10) and a height of 1.0e7, and 
then called the glyphRangeForTextContainer method.

I have not called begin editing or end editing at all, and there are no 
unmatched begin and end editing calls in my code, and there are no other 
threads editing the text storage. Nothing that I can see that would trigger 
this.

I have not been able to reproduce the problem here.

I'd be interested in any suggestions of things to look for which may be 
triggering this error.

Thanks


Gideon





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSSplitView and autosave

2011-08-30 Thread Andreas Mayer
NSSplitView's autosave is not working in an existing project of mine.

I created a small test project and there autosave works as intended.
When I create the same test window in a nib of my existing project, it doesn't.

The subview frames' data is correctly saved in the prefs file. But when the 
application is started next time, the split view will not show any subviews at 
all. The splitter is at the very top and the region below is empty.

Now, I worked around the problem by subclassing NSSplitView. That didn't take 
all that long and does what I want.
But I'd still like to know why the built in method fails.

So, any ideas anyone?

(This is on 10.7.1 with Xcode 4.1, latest SDK)


Andreas___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: drag and drop not working between windows on 10.7

2011-08-30 Thread Raleigh Ledet

On Aug 29, 2011, at 11:03 PM, Michael Link wrote:

> I have a document based app that has a source list (NSOutlineView) that 
> allows drag and drop on itself or another source list (same class) in a 
> different document in the same application.
> 
> Everything works on 10.6, in 10.7 drags to the same NSOutlineView are 
> validated as I expect. Drags to the other source list in a different document 
> (different window) are momentarily validated but then immediately 
> invalidated. I can confirm that 

This is odd. If it's all in the same process, and it works in one case, it 
should work in the other. This makes me suspect your code.

> 
> - (NSDragOperation)outlineView:(NSOutlineView*)outlineView validateDrop:(id 
> )info proposedItem:(id)item 
> proposedChildIndex:(NSInteger)index
> 
> is returning the correct operation (copy), but for some reason it doesn't 
> stick. Is there some side effect of the new dragging sessions that might be 
> causing this?

Possibly. But if you haven't  adopted the new dragging session API, the old API 
should still work. Please file a radar and supply a sample project. The sample 
project if very important to help us solve these kinds of issues.

-raleigh

> I don't see any other delegate methods that would interfere with the drag 
> operation like this.
> 
> --
> Michael___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com
> 
> This email sent to le...@apple.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


New Autosave behavior and NSDocument initializers

2011-08-30 Thread Kyle Sluder
Hi all,

Our applications support creating new documents from templates. The
current way we do this is to trap attempts to open files of our
template type in -application:openFile:, call the standard
NSDocumentController path as if we were opening that file, but then
send the resulting NSDocument a -becomeUntitledWithType: message that
does the following:

- (void)becomeUntitledWithType:(NSString *)docType {
  [self setFileURL:nil];
  [self setDisplayName:nil];
  [self setFileType:docType];
  [self setAutosavedContentsFileURL:nil];
  [self setDisplayName:nil];
}

I was wondering if this is still sufficient to mimic the creation of a
fresh new document given the new autosave behavior on 10.7, or if
there is more bookkeeping (perhaps on the NSDocumentController side of
things) that I need to take care to reset.

I've been studying the new file saving and loading path: http://db.tt/9yzEKle

The thought had crossed my mind that I'd need to replicate its work in
order to support templates. But it doesn't look like that's
necessarily required, though I'll probably not be able to return YES
from +canConcurrentlyReadDocumentsOfType: when passed my template file
type.

Is there anything I'm missing?

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: August Cocoaheads - Silicon Valley Meeting

2011-08-30 Thread Eric Wing
My monster 2 hour presentation on Audio on iOS & OpenAL is finally
available on YouTube.
http://www.youtube.com/watch?v=6QQAzhwalPI

Thanks,
Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/


On 8/17/11, Eric Wing  wrote:
> Reminder: Cocoaheads Silicon Valley is tomorrow. There is a room
> change. Go here for info:
> http://groups.google.com/group/cocoaheads---silicon-valley
>
>
> So I'm still unclear what the itinerary is, so I'm going to take the
> initiative and claim I will be presenting.
>
> I will present Audio on iOS and OpenAL, from my book Beginning iPhone
> Games Development. Among some of the things I will discuss are Audio
> Sessions, AVAudioPlayer, and lots of OpenAL (possibly more than has
> ever been presented in a talk).
>
>
> Also, we (urgently) need a volunteer with a video camera and
> microphone to record the talk. We would like to record the session and
> post it on the Internet as in prior Cocoaheads tradition.
>
> Thanks,
> Eric
> --
> Beginning iPhone Games Development
> http://playcontrol.net/iphonegamebook/
>
>
>
> On 8/5/11, Tedd Fox  wrote:
>> Thanks AGAIN to David Oster and Google, Inc.,
>>
>> Silicon Valley - Cocoaheads 2.0!
>> When:
>> August 18, 2011
>> 7-9PM
>> Where:
>> Bodega Bay Tech Talk Room
>> 1950 Amphitheater Parkway Mountain View, California
>>  Directions are here:
>> http://www.svmug.org/groups/svmug/wiki/6def0/BODEGA_BAY_ROOM.html
>>
>> We still need people for speakers.
>>
>> We have to discuss SOMETHING open source every meeting.
>> If you have any questions, suggestions, anything, let me know.
>>
>> Be #awesome,
>>
>> Tedd Fox
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/ewmailing%40gmail.com
>>
>> This email sent to ewmail...@gmail.com
>>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


stdout or stderr file path on iPhone?

2011-08-30 Thread Manfred Schwind
Hi,

is there a file path to the console output - visible in Xcode, e.g. when 
calling NSLog, I think it's stderr - on the iPhone?
I tried "/dev/stderr" or "/dev/fd/2" (and several other paths) but they do not 
work and if I get the directory contents of "/dev" they really don't exist on 
iOS.

stdout and stderr of the stdlib work fine, but they don't reveal their 
corresponding file paths (if there is any), if I see it right. But I really 
need a file path; a file handle or FILE struct does not help any further.

Background: I have a third party library (that I am not allowed to change) that 
logs to a file in Debug mode. I want to see this log output directly in the 
Xcode console, because transferring log files from the iPhone is too 
complicated. The library provides an API to set the file path (unfortunately 
not a file handle or something else).

Any ideas?

Regards,
Mani
--
http://mani.de - friendly software
iVolume - listen to music hands-free
Lullaby - wicked awesome shutdown timer
Secrets - secure information storage
LittleSecrets - the encrypted notepad
Watchdog - baffle the curious
Sahara - sand in your pocket

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: stdout or stderr file path on iPhone?

2011-08-30 Thread Chris Markle
Manfred,

> Background: I have a third party library (that I am not allowed to change) 
> that logs to a file in Debug mode. I want to see this log output directly in 
> the Xcode console, because transferring log files from the iPhone is too 
> complicated. The library provides an API to set the file path (unfortunately 
> not a file handle or something else).

>From OS/X man pages and I'm thinking this probably works as well on
iOS, although I didn't test it:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man4/stdout.4.html

So e.g., stdout would be /dev/stdout. See if that works for you...

Chris
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Won't Applescript command use defined ivars?

2011-08-30 Thread Chris Paveglio
I am starting to work on an application that must expose 1 Applescript command. 
(It's rather challenging to understand and implement.)
I don't understand what is happening with this code: If I have an ivar that is 
global in scope, when the Applescript command is accepted, that ivar won't be 
used. Why would that be ignored at all? What am I missing here?
Chris

For example (code simplified):

@interface...
{
NSString *userName;
}

@implementation...

-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    userName = NSUserName();
}

-(id)performDefaultImplementation
{
NSDictionary * theArguments = [self evaluatedArguments];
NSString *filePath = [self directParameter];

NSNumber *tcNumber = [theArguments objectForKey:@"tcNumber"];
NSString *operationType = [theArguments objectForKey:@"operationType"];
//the globals won't pass in properly when called from script
[self logEventDoc:filePath operType:operationType withTC:[tcNumber longValue]];
return nil;
}


-(void)logEventDoc:(NSString *)docPath operType:(NSString *)opType 
withTC:(long)tcNumber
{
NSString *theCommand = [NSString stringWithFormat:@"SpLogEventEtc %@ %D %@ %@", 
docPath, tcNumber, opType, userName];
//for testing, let's just do our favorite NSLog
NSLog(@"%@", theCommand);
//user name prints as (NULL) !!?? Why not using userName?
}
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: stdout or stderr file path on iPhone?

2011-08-30 Thread Manfred Schwind
> From OS/X man pages and I'm thinking this probably works as well on iOS

That's what I thought, too. But unfortunately it doesn't work.

> So e.g., stdout would be /dev/stdout. See if that works for you...

Does not work. I tried that:

[@"\n\nTEST\n\n\n" writeToFile:@"/dev/stdout" atomically:NO 
encoding:NSUTF8StringEncoding error:NULL];

I get the output when running the app in the Simulator, but not when running it 
on the device.
Then I tried this:

NSLog(@"Contents of /dev:\n%@", [[NSFileManager defaultManager] 
contentsOfDirectoryAtPath:@"/dev" error:NULL]);

In the Simulator I get a long list including stdin, stdout, stderr etc.
But on the device I just get this:

---
Contents of /dev:
(
console,
tty,
null,
zero,
klog,
pf,
ttyp0,
ptyp0,
ttyp1,
ptyp1,
ttyp2,
ptyp2,
ttyp3,
ptyp3,
ttyp4,
ptyp4,
ttyp5,
ptyp5,
ttyp6,
ptyp6,
ttyp7,
ptyp7,
ttyp8,
ptyp8,
ttyp9,
ptyp9,
ttypa,
ptypa,
ttypb,
ptypb,
ttypc,
ptypc,
ttypd,
ptypd,
ttype,
ptype,
ttypf,
ptypf,
ptmx,
vn0,
vn1,
bpf0,
bpf1,
bpf2,
bpf3,
random,
urandom,
"cu.iap",
"tty.iap",
"uart.iap",
"cu.gas-gauge",
"tty.gas-gauge",
"uart.gas-gauge",
io8log,
io8logmt,
disk0,
rdisk0,
disk0s1,
rdisk0s1,
"aes_0",
"sha1_0",
"mux.spi-baseband",
"cu.debug",
"tty.debug",
"uart.debug",
"cu.umts",
"tty.umts",
"uart.umts",
"cu.bluetooth",
"tty.bluetooth",
"uart.bluetooth",
btreset,
btwake,
disk0s2,
rdisk0s2,
disk0s2s1,
rdisk0s2s1,
disk1,
rdisk1,
"dlci.spi-baseband.call",
"dlci.spi-baseband.reg",
"dlci.spi-baseband.sms",
"dlci.spi-baseband.low",
"dlci.spi-baseband.pdp_ctl",
"dlci.spi-baseband.chatty",
"dlci.spi-baseband.cl1",
"dlci.spi-baseband.pdp_0",
"dlci.spi-baseband.pdp_1",
"dlci.spi-baseband.pdp_2",
"dlci.spi-baseband.iq",
"dlci.spi-baseband.pdp_3",
"dlci.spi-baseband.extra_0",
ttys000
)
---

I tried /dev/console and /dev/tty and some others, but nothing lands in the 
Xcode console.

Some more ideas?

Regards,
Mani
--
http://mani.de - friendly software

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UIBarButtonItem exclusive touch

2011-08-30 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/29/11 11:51 PM, Leon Qiao wrote:
> Hi,
> 
> Thanks for your response ! I missed something.In the thread method
> "saveTheData", I do call the popToRootViewController on the main
> thread by using "performSelectorOnMainThread:".

OK; that's an important detail to note.

While this is then technically acceptable, it still seems like a
strange design.  What it sounds like it will do is perform a save in
the background then, when finished, pop the nav controller.  Is this
what you really want?  Presumably you are multithreading the save
operation since it could potentially take a while and you don't want
to block user interaction (*good*).  But then you are going to
abruptly pop the nav controller, potentially in the middle of whatever
else the user might have been doing (*bad*).

(I'm also a little unclear as to why an "add" button has a "save"
action; I'm assuming you meant "add" as an analogy to the contacts app
as stated, with your actual button being a "save" button in the same
location.)

So here's my question: do you actually want the save action to prevent
the user from continuing display/edit?  If so, throw up some sort of
modal view with, say, a UIProgressView, so the user knows a save is
happening but keep the save on a background thread (if for no other
reason than to prevent the watchdog from killing your app).  If not,
keep the save on the background thread but lose the navigation
controller action, letting it quietly complete (but display a message
if the save fails).

> It seems that both of the two functions(saveAction: and
> tableView's delegate method) are invoked. And the navigation
> controller first pop all view controllers to the root. And then
> push the detail view controller, and sometimes it push to the
> detail view and then pop to the root. So is there any tips about
> the synchronization?

And now to your original question, which probably still applies
regardless of how you handle the above issue... please see my comments
below.

> On Aug 29, 2011, at 19:34, Leon Qiao  > wrote:
> 
>> When using UIButton, we can set the exclusive touch property to
>> avoid tapping the two buttons at the same time. But what should I
>> do for
> the table
>> view and the bar button item.

Well, the exclusiveTouch property is defined for UIView, so
UITableView (and its components) can be set to have exclusive touches.

I had forgotten that UIBarButtonItem does not inherit from UIView, so
that is an interesting little puzzle.  I notice that in the contacts
app the behavior seems deterministic, so there is something going on
to handle synchronization.

My first wild guess as to how you might do this without exclusive
touches is to have the "lower priority" action (i.e. whichever you
would not want performed if there were a conflict) use a delayed
perform (you probably only need delay 0 to kick it into the next run
loop iteration) and have the "higher priority" action start by
canceling any previous delayed performs.  There may be a more elegant
solution, but this is the usual approach for situations such as
distinguishing between single- and double-taps (at least in the days
before gesture recognizers, which presumably are using this mechanism
under the hood).

Since you are familiar with performSelectorOnMainThread: I'm going to
guess you have also encountered delayed performs before, but if not
you will want to take a look at NSObject's

– performSelector:withObject:afterDelay:

and

+ cancelPreviousPerformRequestsWithTarget:selector:object:


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOXT4naOlrz5+0JdURAqOnAJ9pzz/Pce9C3yGIKoMHVh8bHbmibACcCYeD
wpNq+ubIp7Xcct0eUZyYeu0=
=cjgQ
-END PGP SIGNATURE-
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Won't Applescript command use defined ivars?

2011-08-30 Thread Scott Ribe
On Aug 30, 2011, at 1:01 PM, Chris Paveglio wrote:

> I am starting to work on an application that must expose 1 Applescript 
> command. (It's rather challenging to understand and implement.)
> I don't understand what is happening with this code: If I have an ivar that 
> is global in scope, when the Applescript command is accepted, that ivar won't 
> be used. Why would that be ignored at all? What am I missing here?

I don't understand your question. There is no such thing as "an ivar that is 
global in scope", and there are no globals, or even statics, in the code that 
you posted. If you have two different instances of whatever class this is, 
they'll have distinct userName ivars. If you only have one instance, then 
userName should only be NULL if you look before applicationDidFinishLaunching 
is called, or you clear it some time after. Now since you didn't alloc/init, or 
create it, you should retain it. But even if it's been released, the ivar will 
have the stale pointer, not null.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: stdout or stderr file path on iPhone?

2011-08-30 Thread Jens Alfke

On Aug 30, 2011, at 11:06 AM, Manfred Schwind wrote:

> is there a file path to the console output - visible in Xcode, e.g. when 
> calling NSLog, I think it's stderr - on the iPhone?
> I tried "/dev/stderr" or "/dev/fd/2" (and several other paths) but they do 
> not work and if I get the directory contents of "/dev" they really don't 
> exist on iOS.

Wow, that is rather weird. You might ask on the darwin-userlevel mailing list 
here, which is all about that level of stuff.

> Background: I have a third party library (that I am not allowed to change) 
> that logs to a file in Debug mode. I want to see this log output directly in 
> the Xcode console, because transferring log files from the iPhone is too 
> complicated. The library provides an API to set the file path (unfortunately 
> not a file handle or something else).

As a workaround you could run a background thread that opens that log file, 
waits for its EOF to increase, and then echoes the appended data to stderr. 
(Basically like ‘tail -n’.)

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: stdout or stderr file path on iPhone?

2011-08-30 Thread Scott Ribe
On Aug 30, 2011, at 2:30 PM, Jens Alfke wrote:

>> Background: I have a third party library (that I am not allowed to change) 
>> that logs to a file in Debug mode. I want to see this log output directly in 
>> the Xcode console, because transferring log files from the iPhone is too 
>> complicated. The library provides an API to set the file path (unfortunately 
>> not a file handle or something else).

Is there any way that could find the file descriptor for that log file, close 
it, fdup it to 3 (stderr)???

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Won't Applescript command use defined ivars?

2011-08-30 Thread Martin Wierschin
> If I have an ivar that is global in scope,

As Scott mentioned, your ivar isn't global. Each instance of your class has its 
own ivar. Also as he mentioned, you seem to be ignoring the memory management 
guidelines. That's not the immediate cause of your troubles, but is important 
for you to understand and fix.

What exactly is your class? Your post omits important parts:

> @interface...
> {
> NSString *userName;
> }

Are you subclassing NSScriptCommand? If so, then I'm guessing that the 
AppleScript machinery is creating a new instance of your class every time you 
run your AppleScript. Which means that your instance is not in existence when 
the -applicationDidFinishLaunching method might be called, and hence why your 
ivar is nil.

~Martin

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: stdout or stderr file path on iPhone?

2011-08-30 Thread Manfred Schwind
>>> Background: I have a third party library (that I am not allowed to change) 
>>> that logs to a file in Debug mode. I want to see this log output directly 
>>> in the Xcode console, because transferring log files from the iPhone is too 
>>> complicated. The library provides an API to set the file path 
>>> (unfortunately not a file handle or something else).
> 
> Is there any way that could find the file descriptor for that log file, close 
> it, fdup it to 3 (stderr)???

Great, thanx! That works like a charm.
Access to the file descriptor is exposed through some preprocessor macros in 
the header of the library.
So now I just grab this file descriptor and do a dup2(STDERR_FILENO, 
fileDescriptor);
Problem solved.

Thank you,
Mani
--
http://mani.de - friendly software

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Large over 100K pixel high ruler scroll view

2011-08-30 Thread Julie Porter

On 8/29/11 10:39 PM, Graham Cox wrote:


NSDocument and NSView are totally unrelated classes.



[...]

So your view will be doing stuff like:

[myDocument giveMeDataForLinesInRange:linesRange];// in -drawRect:

and your document will be doing stuff like:

[myView setFrame:theSizeICalculatedFromTheData];

Sorry to keep this going.  I am hopelessly lost in the Class and 
Instance abstractions here.  I do not think I am alone as I feel I have 
spent most of the day with google. Reading the fustrations and confusion 
of others, who can not quite seem to "see the light."


I have an array of dictionaries.  This is defined in the MyDocument 
class.  Inside MyDocument.m  I can read, load  NSLog and do anything I 
want with this structure.


The basic for this is really simple.



Reading a bunch of stuff online, I found how to use X code scripts and 
create getters and setters.  This gave me a whole bunch of acessors, 
most of what make sense.  like:



Problem is when I want to see this array in my view class file 
CISView.m   Which is based on the RulerView sample code.  I define a 
simple logline.


NSLog(@"have %lu events.",[[MyDocument CISEvents] count]);

I get the error:
 'MyDocument' may not respond to '+CISEvents'

Tried changing the + to - and got 'instance variable '' accessed in 
class method.' all over the MyDocument.m file.



After a day of reading I see things saying I may need to create a 
"singleton." in the CISView.m file.  Other more confusing helpful 
suggestions have stuff set in interface builder and setting outlets and 
such.  But I am dealing with the database  linedrawing into cliprects 
and scrollbars, not calculators iPhone apps and such.


The closest I found was to try something like:

standardCISDocument = [[MyDocument alloc] init];
NSLog(@"have %lu events.",[[standardCISIDocument CISEvents] count]);

The code I want to use for my view is based on the NSRuler sample code.  
This has a +initialize to set the ruler graticule.  I need to set the 
ruler graticule dependent on information inside one of the array 
dictionaries.


The compiler will not let me put the above code into +initialize as it 
complains about instance abstractions that are confusing.   the same 
'instance variable '' accessed in class method. warning. If one has an 
accessor, then why can it not access?


I read all about car and factory methods classes and such.  Not to 
mention examples relating to apples oranges and bananas.


But no where do I see a clear concise explanation for 35+ year assembly 
language postscript C language programmers who still believe with 
religious dogma that ints are pointers and pointers are ints!   I never 
liked private variables, but am open to evangelical conversion if the 
arguments are clear.


The apple documentation is so curcumlocutious as to feel like a works 
program for out of work document writers.   Where are the code examples 
next to the class instance declarations.  Again what files do things go 
into?  It is all about where in the files to put things.


I tried putting the above "singleton" code in -awakefromNib, but I get 0 
count. The View awake is called before the MyDocument awake but after 
the -readfromURL stuff.


I tried adding a plain -init.  This never seems to get called.  It seems 
like there are too many ways to do things and ever so much overhead, 
which is good when paid by the hour. Not so good when writing shareware 
and customware for oneself.


I have all of this working in Carbon/Quickdraw.  Plus another postscript 
file that does exactly what I want.  Not sure what is more of a waste of 
time, maintaining that or learning cocoa.  Problem is my 5 powerpc 
computers are not going to be of much use soon, so will need this to run 
on what ever I can get.


I keep going over the cocoa tutorials, but they are completely set on 
doing what has been done before.   I got buttons down,  I got 
departments and employees down to make great lists of data.


I just can not figure out how to get my data array across multiple *.m 
files   to initialize  frame abstraction and call  drawRect.  So that I 
can scroll 25,000 to 10,000 lines.  withouth having to create image data 
sources, since my images are lines draw on as as needed basis.



-julie








___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Large over 100K pixel high ruler scroll view

2011-08-30 Thread Jens Alfke

On Aug 30, 2011, at 8:43 PM, Julie Porter wrote:

> NSLog(@"have %lu events.",[[MyDocument CISEvents] count]);
> 
> I get the error:
> 'MyDocument' may not respond to '+CISEvents'

This is the distinction between a class and an object. A class is a kind of 
template that defines what data objects contain. It doesn’t make any sense to 
use [MyDocument CISEvents]; it’s like asking “how many spots does the word 
Leopard have?”. Properties apply to individual objects, not to classes. This is 
pretty fundamental, and a lot of other things in Cocoa programming (as with 
Java or many other languages) won’t make sense until you’ve got it down.

I think the other thing you’re having trouble with is how to have the different 
objects (not classes) in your app refer to each other. A pretty common way to 
do this is for the controller object (the document in your case) to initialize 
the view right after it loads by telling it where the model object is. In your 
case I’m assuming the array of events is the data model.

So one solution is to give your view class a settable property that’s also an 
array of events, and have the document set that property on the view after the 
window loads. Typically you’d give the document class an IBOutlet pointing to 
the view, and wire that up in IB. Then as soon as the nib loads, the document 
knows the view and can initialize it.

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Large over 100K pixel high ruler scroll view

2011-08-30 Thread Jens Alfke

On Aug 30, 2011, at 8:43 PM, Julie Porter wrote:

> I just can not figure out how to get my data array across multiple *.m files  
>  to initialize  frame abstraction and call  drawRect. 

It really has nothing to do with files. You could put your entire program into 
one source file (in the correct order) and it would compile and run. It has to 
do with what classes you have and what instance variables, properties and 
methods those classes have. You can draw this out on paper if it makes it 
clearer, with boxes for the classes and lines for references between them (i.e. 
instance variables that are pointers to other objects.)

> But no where do I see a clear concise explanation for 35+ year assembly 
> language postscript C language programmers who still believe with religious 
> dogma that ints are pointers and pointers are ints!   I never liked private 
> variables, but am open to evangelical conversion if the arguments are clear.

You might need to back up a bit and find some good introductory books on 
object-oriented programming. This stuff has been around for a long time 
(Simula-67 and Smalltalk-72 started it) but it’s become mainstream more 
recently. It’s definitely a level of abstraction above procedural programming, 
but it scales much better. Unfortunately I don’t know what books to recommend. 
I was lucky enough to get into OOP really early (1984, in Smalltalk-80) so it’s 
like I’m a fish trying to explain how to swim.

I wonder if this stuff would click better for you if you read a low-level 
explanation of how it’s implemented. Classes are tables that associate message 
names (selectors) with function pointers, and objects are structs that start 
with an invisible pointer to their class, and calling a method is a lookup that 
indirects through the object’s class hierarchy one level at a time until it 
finds the desired selector, then calls the associated function (passing ‘self’ 
as an invisible parameter pointing to the object.) I’m not sure if Apple’s 
Objective-C language book goes into this. The classic Smalltalk-80 ‘Blue Book’ 
does, I’m pretty sure.

Anyway, I think the most important thing I can say is that this isn’t something 
you can plow straight into. You need to back up and absorb some theory, because 
you’re so used to a very different way of working that you’re not going to be 
able to absorb the OOP way just in the course of working tutorials.

The Wikipedia article on Object-Oriented Programming seems to go into some 
detail (and links to other articles like Dynamic Dispatch that provide more). 
It also has a lot of references to useful-sounding books.
http://en.wikipedia.org/wiki/Object-oriented_programming

—Jens___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Large over 100K pixel high ruler scroll view

2011-08-30 Thread Julie Porter

On 8/30/11 8:59 PM, Jens Alfke wrote:


On Aug 30, 2011, at 8:43 PM, Julie Porter wrote:


NSLog(@"have %lu events.",[[MyDocument CISEvents] count]);

I get the error:
'MyDocument' may not respond to '+CISEvents'


This is the distinction between a class and an object. A class is a 
kind of template that defines what data objects contain. It doesn’t 
make any sense to use [MyDocument CISEvents]; it’s like asking “how 
many spots does the word Leopard have?”. Properties apply to 
individual objects, not to classes. This is pretty fundamental, and a 
lot of other things in Cocoa programming (as with Java or many other 
languages) won’t make sense until you’ve got it down.


I think the other thing you’re having trouble with is how to have the 
different objects (not classes) in your app refer to each other. A 
pretty common way to do this is for the controller object (the 
document in your case) to initialize the view right after it loads by 
telling it where the model object is. In your case I’m assuming the 
array of events is the data model.


I have the idea that a class,  MyDocument is instantiated with an array 
myEvents,  each time a file is opened.


A separate class MyView is opened by MyDocument by some sort of magic in 
the controller glue.


I can see how the MyView class has no understanding of the myEvents 
object as  there is no clear connection to the MyDocument class other 
than the controller magic.


What I do not get, is why an accessor such as an abstract getObject can 
not get the Object from the open and instantiated MyDocument class.   I 
guess it need to have a link or line to the object in the MyDocument 
class, since there is an instance of MyView spawned by the MyDocument, 
it would seem that there should be a link between the two, but where is 
this link hidden?  Or do I need to make it programmatically?



So one solution is to give your view class a settable property that’s 
also an array of events, and have the document set that property on 
the view after the window loads. Typically you’d give the document 
class an IBOutlet pointing to the view, and wire that up in IB. Then 
as soon as the nib loads, the document knows the view and can 
initialize it.


This is even more confusing,  What does IB have to do with my database 
and communication between functions?  I thought this was for things like 
buttons and cells so that when one presses a button the value in a cell 
is passed to the function.


I think I need to look up the definition of property.  That may be what 
I am not understanding.  That I abstract property and key as the same 
thing.



Will attempt to read more on IB Outlet abstractions, but am not sure 
what an IBOutlet is in relation to my array of events.  Which I am 
pretty sure is the Data Model.  (apart from the arrays of dicts I could 
draw the keys and values using the list view CoreData tools.)


In postscript I have  a dictionary open on the stack that contains my 
array of dictionaries.  If I open another dictionary on the stack I can 
read in my array, but any new define instances are declared in local to 
the new dictionary.  When I close that top level dictionary  I can no 
longer access any local changes.


I think cocoa is the other way around,  Where the document which has the 
array of dictionaries I want is not visible to the View because the view 
is not open to the document.


I also keep seeing stuff relating to KVO.   This relates to the really 
nifty Departments and employees type list, that sort of seem to happen 
with bindings.  But that system will not let me have arrays  of dicts 
inside arrays of dicts unless I can program them through classes or what 
ever abstraction I am failing to understand.  Problem is I am not 
writing mail or iTunes, that has already been done.


I think KVO is what, in the long term, I want.  Connecting things in IB 
seems even more like going down the wrong path.   Again in postscript I 
have keys and values.  This is what is in my dictionary.  One key might 
be @"StartLine"  another key abstracts as @"EndLine"


I have keys and values.  I want to observe them between classes.  
Nothing more, nothing less.


Saw the second part relating to OoP as they used to call it.  I remember 
liking smalltalk and Logo, but I was in high school at the time 35 years 
ago. the world went to procedural programming.  A lot of this really 
feels like a waste of time.  Makework for programmers.  I thought the 
point of such was to abstract things so that one can concentrate on the 
not so common code.



There really should be a framework tutorial out there that works for 
scrolling graphics the same way one can scroll text.  A black box where 
one only has to deal with the drawRect procedure that is file based.


-julie

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-a

Linking an NSWindow in IB

2011-08-30 Thread Guy Halford-Thompson
This is somewhat of a basic question, but I am having a lot of trouble
getting it to work.

When my app loads, I check for certain parameters, and then display an NSWindow.

I have created the window in IB and also created a custom class
(MyWindow).  in IB I have given the window class MyWindow.

I have added a couple of extra functions to MyWindow and now I wish to
trigger the window to be displayed given certain conditions.

How can I display the window?

I have tried

MyWindow *win = [[MyWindow alloc] init];
[win makeKeyAndOrderFront:nil];

but it just displays a blank window...

I am pretty sure that I have not linked the window from IB properly
but I am really confused about how to do it and the apple
documentation / google don't seem to be able to help.

Thanks for any help


-- 
Guy Halford-Thompson
Blog                  - http://www.cach.me/blog
Twitter               - https://twitter.com/mrwooster
Google Plus       - http://gplus.name/guy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


LLVM 2.1 Error

2011-08-30 Thread Bruce Cresanta
Hello All!

I am trying to port my app from Xcode 3.5 to Lion 4.1.   I can't get a 
clean compile.   I keep getting the following error:


clang: error: no such file or directory: 
'/Volumes/Volume/proSEOLion/proSEO/proSEO/proSEO-Prefix.pch'
clang: error: no input files
Command /Developer/usr/bin/clang failed with exit code 1

I've checked the PCH settings in the Linker Section of the Target.   Nothing is 
out of the ordinary.   Can you suggest why this is happening?

Thanks,

Bruce


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: LLVM 2.1 Error

2011-08-30 Thread Bruce Cresanta

On Aug 29, 2011, at 11:04 PM, Bruce Cresanta wrote:

> Hello All!
> 
>   I am trying to port my app from Xcode 3.5 to Lion 4.1.   I can't get a 
> clean compile.   I keep getting the following error:
> 
> 
> clang: error: no such file or directory: 
> '/Volumes/Volume/proSEOLion/proSEO/proSEO/proSEO-Prefix.pch'
> clang: error: no input files
> Command /Developer/usr/bin/clang failed with exit code 1
> 
> I've checked the PCH settings in the Linker Section of the Target.   Nothing 
> is out of the ordinary.   Can you suggest why this is happening?
> 
> Thanks,
> 
> Bruce
> 
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com