RE: literal strings - who do they belong to?
Unfortunately, this contract isn't always followed. Lots of people optimise away this policy instead of doing a superfluous 'return [[foo retain] autorelease]'. On initial read, I didn't quite follow this. If my method is returning a foo that I know I have retained, what requirement is there on me to bump the retain count temporarily? Even if I have an object whose nominal retain count is zero (ie, its going to disappear on the next autorelease-pool-drain), surely the superfluous [[foo retain] autorelease] only gives it a life while its in the stack frame, which is to say nothing extra. Its not my problem if the guy who called me has his own pool that will be free'd when he returns? But then I saw the case where I have an object which returns, as a method result or a property, one of its instance variables. The caller holds on to it (without retaining it) then releases (and deallocs) my object. My object releases its instance variables which results in the caller holding a reference to a dead value. { Object *o = [Object new]; NSString *s = o.somevalue;// gets o's instance variable (without retain) [o release]; // o's instance variable is released NSLog(@Crash: %@,s) // accesses dead string } So, yes, the retain/autorelease isn't superfluous at all, though the usage pattern that would trigger the problem seems relatively unlikely (in my example, o seems far more likely to be autorelease'd). Is there a more common case that I'm missing? ___ 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: [iPhone] Addressbook group problem
Ditto that. Luke Sent from my iPhone. On Jul 12, 2009, at 10:15 PM, Roland King r...@rols.org wrote: ABAddressBookCopyArrayOfAllGroups()? James Lin wrote: Hi, Sorry I didn't frame my question more clearly... The part I am having trouble with is finding out if a group name already exists in the addressbook, is there a way to do this? the ABGroup documentation has no function that allows this... any suggestions? Thank you in advance... James On 2009/7/11, at 下午 9:36, Luke Hiesterman wrote: The group doesn't have a name when you create it. Try setting the name after creation rather than getting it. Luke Sent from my iPhone. On Jul 11, 2009, at 12:50 AM, James Lin jamesclin...@gmail.com wrote: Hi all, Anyone familiar with the Addressbook framework? I can't seem to be able to add a group into the addressbook only ONCE. if i use ABRecordRef group = ABGroupCreate(); to get a handle on group, calling NSString *groupName = (NSString *) ABRecordCopyCompositeName(group); returns a NULL. so I can't seem to be able to check if a group name already exists and don't have to re-create the group again. Can you please help me and point me in the right direction? How do I create group only once? Thank you and best regards... James ___ 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/luketheh%40apple.com This email sent to luket...@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/rols%40rols.org This email sent to r...@rols.org ___ 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: literal strings - who do they belong to?
But then I saw the case where I have an object which returns, as a method result or a property, one of its instance variables. The caller holds on to it (without retaining it) then releases (and deallocs) my object. My object releases its instance variables which results in the caller holding a reference to a dead value. { Object *o = [Object new]; NSString *s = o.somevalue;// gets o's instance variable (without retain) [o release]; // o's instance variable is released NSLog(@Crash: %@,s) // accesses dead string } So, yes, the retain/autorelease isn't superfluous at all, though the usage pattern that would trigger the problem seems relatively unlikely (in my example, o seems far more likely to be autorelease'd). Is there a more common case that I'm missing? If o were in an NSDictionary that was passed to you in a parameter, for example, and you removed the key from the dictionary, you'd trigger the same problem. -BJ ___ 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: [iPhone] Addressbook group problem
Thank you Roland. Actually, I tried that function...but there is a problem that I can't figure out. the following is my code segment... ABAddressBookRef addressBook=ABAddressBookCreate(); CFArrayRef grpval= ABAddressBookCopyArrayOfAllGroups(addressBook); CFIndex groupCount = ABAddressBookGetGroupCount(addressBook); CFRange range = CFRangeMake(0, 1); NSArray *convertedArray = (NSArray *)grpval; if (CFArrayContainsValue(grpval, range, @Dangle Three)) { NSLog(@Yes, it contains the group); } NSLog(@tthe group count is %d, groupCount); NSLog(@the group name is %@, (NSString *)CFArrayGetValueAtIndex(grpval, 0)); NSLog(@The converted group is nsarray %@, [convertedArray objectAtIndex:0]); the output i get from the NSLog statements are: 2009-07-13 14:29:08.686 KSOne[7520:20b] tthe group count is 1 2009-07-13 14:29:08.687 KSOne[7520:20b] the group name is NSCFType: 0x119e1a0 2009-07-13 14:29:08.688 KSOne[7520:20b] The converted group is nsarray NSCFType: 0x119e1a0 For some reason, the toll-free bridging doesn't work. although i can get the count of the group array of 1 correctly, the actual group name remains illusive to me :( any ideas? what's NSCFType? what am I doing wrong? Thank you in advance... James On 2009/7/13, at 下午 1:15, Roland King wrote: ABAddressBookCopyArrayOfAllGroups()? James Lin wrote: Hi, Sorry I didn't frame my question more clearly... The part I am having trouble with is finding out if a group name already exists in the addressbook, is there a way to do this? the ABGroup documentation has no function that allows this... any suggestions? Thank you in advance... James On 2009/7/11, at 下午 9:36, Luke Hiesterman wrote: The group doesn't have a name when you create it. Try setting the name after creation rather than getting it. Luke Sent from my iPhone. On Jul 11, 2009, at 12:50 AM, James Lin jamesclin...@gmail.com wrote: Hi all, Anyone familiar with the Addressbook framework? I can't seem to be able to add a group into the addressbook only ONCE. if i use ABRecordRef group = ABGroupCreate(); to get a handle on group, calling NSString *groupName = (NSString *)ABRecordCopyCompositeName(group); returns a NULL. so I can't seem to be able to check if a group name already exists and don't have to re-create the group again. Can you please help me and point me in the right direction? How do I create group only once? Thank you and best regards... James ___ 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/luketheh%40apple.com This email sent to luket...@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/rols%40rols.org This email sent to r...@rols.org ___ 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: [iPhone] Addressbook group problem
Well they aren't strings, they are some kind of opaque type which represents a group. So you can't find it using CFArrayContainsValue with a String. The name is a property of the Group object which is returned. You'll have to iterate the array, get the property for each group which is the name and test it against the name you want to add. This is all documented in the Address Book Programming Guide For iPhone OS whereh it explains what records are and tells you how to get properties out of them. The ABGroup Reference documentation then tells you what the one single property for a group is. (kABGroupNameProperty) Can't say this is the easiest documentation to fully understand on the first reading but bouncing around a bit you should be able to sort out how it works (and if you have documentation improvement suggestions you should hit the link at the bottom and make some, I'm just about to!) James Lin wrote: Thank you Roland. Actually, I tried that function...but there is a problem that I can't figure out. the following is my code segment... ABAddressBookRef addressBook=ABAddressBookCreate(); CFArrayRef grpval= ABAddressBookCopyArrayOfAllGroups(addressBook); CFIndex groupCount = ABAddressBookGetGroupCount(addressBook); CFRange range = CFRangeMake(0, 1); NSArray *convertedArray = (NSArray *)grpval; if (CFArrayContainsValue(grpval, range, @Dangle Three)) { NSLog(@Yes, it contains the group); } NSLog(@tthe group count is %d, groupCount); NSLog(@the group name is %@, (NSString *)CFArrayGetValueAtIndex(grpval, 0)); NSLog(@The converted group is nsarray %@, [convertedArray objectAtIndex:0]); the output i get from the NSLog statements are: *2009-07-13 14:29:08.686 KSOne[7520:20b] tthe group count is 1* *2009-07-13 14:29:08.687 KSOne[7520:20b] the group name is NSCFType: 0x119e1a0* *2009-07-13 14:29:08.688 KSOne[7520:20b] The converted group is nsarray NSCFType: 0x119e1a0* * * *For some reason, the toll-free bridging doesn't work.* *although i can get the count of the group array of 1 correctly, * *the actual group name remains illusive to me :(* * * *any ideas? * *what's NSCFType?* *what am I doing wrong?* * * *Thank you in advance...* * * *James* On 2009/7/13, at 下午 1:15, Roland King wrote: ABAddressBookCopyArrayOfAllGroups()? James Lin wrote: Hi, Sorry I didn't frame my question more clearly... The part I am having trouble with is finding out if a group name already exists in the addressbook, is there a way to do this? the ABGroup documentation has no function that allows this... any suggestions? Thank you in advance... James On 2009/7/11, at 下午 9:36, Luke Hiesterman wrote: The group doesn't have a name when you create it. Try setting the name after creation rather than getting it. Luke Sent from my iPhone. On Jul 11, 2009, at 12:50 AM, James Lin jamesclin...@gmail.com mailto:jamesclin...@gmail.com wrote: Hi all, Anyone familiar with the Addressbook framework? I can't seem to be able to add a group into the addressbook only ONCE. if i use ABRecordRef group = ABGroupCreate(); to get a handle on group, calling NSString *groupName = (NSString *)ABRecordCopyCompositeName(group); returns a NULL. so I can't seem to be able to check if a group name already exists and don't have to re-create the group again. Can you please help me and point me in the right direction? How do I create group only once? Thank you and best regards... James ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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/luketheh%40apple.com This email sent to luket...@apple.com mailto:luket...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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/rols%40rols.org This email sent to r...@rols.org mailto:r...@rols.org ___ 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: [iPhone] Addressbook group problem
Hi Roland, Luke... Thank you for your pointers... the following finally works... ABRecordRef group = CFArrayGetValueAtIndex(grpval, i); NSString *groupName = (NSString *)ABRecordCopyCompositeName(group); Thank you for your pointers and help...sincerely appreciated! James ___ 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: literal strings - who do they belong to?
On Jul 13, 2009, at 1:22 AM, Jeff Laing wrote: { Object *o = [Object new]; NSString *s = o.somevalue; // gets o's instance variable (without retain) [o release]; // o's instance variable is released NSLog(@Crash: %@,s)// accesses dead string } Wouldn't this generally be something that common sense would tell you not to do, anyway? Working with an object's internal state after it's been released isn't a particularly safe thing to do, and can't always be made to behave correctly anyway. For example, you'd never do a thing like this: { NSData *data = [[NSData alloc] initWithBytes:foo length:bar]; const char *bytes = [data bytes]; [data release]; CrashByDoingSomethingWithBytes(bytes); } Why should this sort of thing be expected to work, just because the property in question happens to be an object? Charles ___ 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: literal strings - who do they belong to?
On 13/07/2009, at 13:55 , Wade Tregaskis wrote: I know you guys probably know this, but to be technically accurate, there is no guarantee the return value of stringByAppendingString returns an autoreleased string. While your point is true, it's not actually a rebuttal - you can assume objects returned from such methods are autoreleased, because that's the contract given. No, that is not the contract. The contract is you do not own them. The contract says nothing about autoreleased. http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html Whether they're cached or singletons or whatever else, they must obey the policy that they'll stick around 'til the next flush of the current thread's current autorelease pool. You just can't safely handle the memory management otherwise, especially in multithreaded cases. This is exactly the misconception that needs to be avoided. Here is a trivial counter example: id obj = [dict objectForKey:@whatever]; [dict release]; NSLog( @this will crash %@, id ); No autorelease pool, no remaining valid until the current autorelease pool is flushed. The contract says You don't own it, don't release it and if you want to keep it, retain/copy it. Unfortunately, this contract isn't always followed. Lots of people optimise away this policy instead of doing a superfluous 'return [[foo retain] autorelease]'. Read the rules, follow the rules. It is not optimising away the return [[foo retain] autorelease], which is explicitly allowed in the rules (That method may also safely return the object to its invoker), it is assuming something about the lifetime of the object you don't own that gets people in to trouble. Enjoy, Peter. -- Clipboard Switching and Macros with Keyboard Maestro Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac http://www.stairways.com/ http://download.stairways.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
Solved: Implementing previous, next, first, last controls in Core Data applications
Hi all, Thanks for the response to this question. After a bit of digging in Interface Builder I realised that the basic bindings for Next and Previous buttons are there, as well as the actions in the NSArrayController. I'm not sure whether this is what the reply below was trying to tell me! Anyway, it turns out to be really easy to do the next and previous buttons. In case it is of use to anyone else, here is what to do. If this is all blindingly obvious, forgive the intrusion! Suppose you have an NSArrayController in a window that you have created as a result of dragging in a Core Data Entity. Add two buttons from the Library to provide the Next and Previous UI controls. Then, taking the Next button as an example, you can set the binding as follows: In the AvailabilityEnabled section in the Inspector Bindings tab, bind to the appropriate NSArrayController. and choose canSelectNext as the Controller Key. Then control-drag from the button to the controller in the main window and choose the selectNext: action. The process for Previous is similar. Anyway, I hope someone else finds this useful. Regards, Ian. -- ianpi...@mac.com 07590 685840 | 01926 811383 On 12 Jul 2009, at 2:48pm, I. Savant wrote: On Jul 12, 2009, at 8:51 AM, Ian Piper wrote: Can anyone tell me whether there are any plug-ins or examples that show how to implement buttons to move forward and backward through a record set in a Core Data application? I am thinking of having a window that simply presents one record from a collection, with forward, backward, first and last buttons. This isn't really a Core Data question, but rather a bindings question. Read up on Cocoa Bindings and NSArrayController. All you need to do is modify the selection as desired when these buttons are pressed via -[NSArrayController setSelectionIndex:] or -[NSArrayController setSelectionIndexes:], keeping in mind the array controller's - arrangedObjects (and the count thereof). If the rest of your detail view is bound to this array controller's selectedObjects.whateverKeys, you're done. -- I.S. ___ 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: NSCondition (unlocked when not locked)
Hey Greg You're not following the pattern laid out in the Overview setion of the NSCondition class reference. In particular, you don't have a boolean predicate, and you're not doing the task's work between the bounds of lock and unlock. Hm ... but if I surround my task's work with lock/unlock wouldn't this block the calling thread until the worker thread has done it's work? - (void) pollNow { [pollingCondition lock]; [pollingCondition signal]; [pollingCondition unlock]; } ...which is absolutely not what I want. Essentially I want something along the lines of this pseudo code: function workNow() { signal = YES } function worker() { while(1) { wait for 1000ms or signal == YES signal == NO do some work } } A boolean predicate is an important part of the semantics of using conditions because of the way signaling works. Signaling a condition does not guarantee that the condition itself is true. There are timing issues involved in signaling that may cause false signals to appear. Right. I read that. But for me false signals are not a problem. I don't really need that guarantee. My only concern is to not have the thread waiting without going through the loop from time to time. cheers -- Torsten ___ 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: Solved: Implementing previous, next, first, last controls in Core Data applications
On Jul 13, 2009, at 5:37 AM, Ian Piper wrote: Thanks for the response to this question. After a bit of digging in Interface Builder I realised that the basic bindings for Next and Previous buttons are there, as well as the actions in the NSArrayController. I'm not sure whether this is what the reply below was trying to tell me! No, you're absolutely right, there are pre-baked -selectNext: and - canSelectNext: methods on NSArrayController about which I completely forgot. -- I.S. ___ 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
Window Resize with Animator Proxy: Window Contents Jump Around
I am trying to resize a window with an animation using the NSAnimatablePropertyContainer animator proxy mechanism. The views have the Wants CA Layer option set in IB. I use this code: NSRect frame = window.frame; frame.size.height += delta; frame.origin.y -= delta; [[window animator] setFrame:frame display:YES]; The problem is that during the animation, the window contens jump down briefly when the window grows, and up when it shrinks. It does not do this when I do not reset the origin by commenting out this line: // frame.origin.y -= delta; But then the window grows upward which is not what I want. I made a screen video here: http://www.youtube.com/watch?v=NARKujk2jrg It also works if I don’t enable the CA layer backing in IB, but I need that because I am going to fade a subview at the same time as I resize the window. Without CA layers I can only hide and show the subview with a hard transition, but I want to fade it. Is there something I should do differently or is this a known issue? ___ 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: NSError in NSDocument readFromURL
If I set an NSError in the method readFromURL of my NSDocument, I am not able to overwrite the NSLocalizedDescriptionKey. ... Unfortunately only the strings of the keys NSLocalizedFailureReasonErrorKey and NSLocalizedRecoverySuggestionErrorKey are displayed together with a standard error text. My own localizedDescription (Description) is not displayed. Instead I got the standard error text The document xyz could not be opened. FailureReasonRecoverySuggestion. Is this a bug, that the string with the key NSLocalizedDescriptionKey is always overwritten before displayed or not displayed at all, if set in readFromURL or is this feature somewhere documented? I could not find anything regarding this at apple. No, the NSError object you create is just fine, but NSDocumentController (which causes the error alert to be displayed) *always* makes the alert say that the document could not be opened. If you want to display your own description, you need to display your own alert before returning from readFromURL:... (using [NSApp presentError:], usually), then return an error with domain=NSCocoaErrorDomain and code=NSUserCancelledError, to suppress NSDocumentController's alert. Thanks for your answer, but is this behaviour somewhere documented? I looked into NSDocumentControllers documentation but nothing about such an error and what is actually evaluated for the standard alert from the given NSError. How did you find out? Simply by try and error? ___ 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
Best 'Cocoa' File Preview
On Monday, July 13, 2009, David Blanton aired...@tularosa.net wrote: Is it not the case that the UTI is defined in the info.plist CFBundleDocumentTypes? (which I have done). Nope, CFBundleDocumentTypes associates your type to the plugin. You should use UTExportedTypes or UTImportedTypes look for declaring UTI in info.plist in google, you'll find exactly what you need. -- Julien ___ 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: Quickly jump to a particular symbol/selector/class ?
Debajit, Right-click (set it up so you can use two fingers on the touch pad) directly on the symbol, then select ³Jump to Definition² from the popup menu. There is no faster way to do this (that I know of). -- Michael Domino michael.dom...@identityfinder.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
Re: NSError in NSDocument readFromURL
If I set an NSError in the method readFromURL of my NSDocument, I am not able to overwrite the NSLocalizedDescriptionKey. Amazing how this works out sometimes - I *just* ran into this yesterday for the first time. Thanks for your answer, but is this behaviour somewhere documented? I looked into NSDocumentControllers documentation but nothing about such an error and what is actually evaluated for the standard alert from the given NSError. How did you find out? Simply by try and error? I've come across the documentation where it specifies the cocoa domain and the magic error code to get the error ignored, but could not figure out why my own error message was not displayed. I thought it might be a you-know-what-version bug but the problem persisted on Leopard and Tiger as well ... I agree there doesn't *seem* to be an explanation of this in the documentation. I read (and re-read) the Document-Based Applications Overview as well as the NSDocument class reference. The overview mentions the coco domain / error code trick for getting the message ignored (and I saw that referenced somewhere else as well), but the documentation for -[NSDocument initWithURL:ofType:error:] says only this about the error pointer pointer: On return, If initialization is unsuccessful, a pointer to an error object that encapsulates the reason the document could not be created. It says nothing about special requirements for displaying it. I think the best place is the overview, though, right along with the Cocoa error domain bit. The NSDocumentController passage for - makeDocumentWithContentsOfURL:ofType:error: says only: If not successful, the method returns nil after setting outError to point to an NSError that encapsulates the reason why the document could not be instantiated. Operative word being an NSError. Funny enough, it ignores your reason and never gives one itself. It just says it could not be opened. :-D I'm tempted to call this an API bug, though, before I file documentation bugs. I would expect it to work as the documentation suggests - if I set an error, display that error, else why the hell are you asking me to supply one? Debate? -- I.S. ___ 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: Quickly jump to a particular symbol/selector/class ?
On Jul 13, 2009, at 9:41 AM, Michael Domino wrote: Right-click (set it up so you can use two fingers on the touch pad) directly on the symbol, then select “Jump to Definition” from the popup menu. There is no faster way to do this (that I know of). That's not quite what was asked, but a faster way to do what you're saying is to Cmd-Double-Click the symbol. But again, this is off-topic. -- I.S. ___ 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: Window Resize with Animator Proxy: Window Contents Jump Around
On Jul 13, 2009, at 7:08 AM, Marc Liyanage wrote: It also works if I don’t enable the CA layer backing in IB, but I need that because I am going to fade a subview at the same time as I resize the window. Without CA layers I can only hide and show the subview with a hard transition, but I want to fade it. Is there something I should do differently or is this a known issue? A warning: I suck at the whole layers / animation thing. :-) Any advice I give is a guess. My guess: I think because you're removing (with or without animation) the bottom field / label, you're changing the autosizing behavior of the content view's contents while it's being moved around. Again, I am likely completely off base, but that's the only explanation I can think of. My suggestion: I have none, really. This is why I said I suck. I'm still trying to learn best practices and general approaches to avoid these kinds of problems. Sorry. :-) I'll be following this thread with great interest, though. (+Flag) -- I.S. ___ 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: NSCondition (unlocked when not locked)
Torsten Curdt wrote: Hm ... but if I surround my task's work with lock/unlock wouldn't this block the calling thread until the worker thread has done it's work? Follow the existing example from Threading Programming Guide, under the Using Conditions section. It's simple and clear. If it doesn't work, then post again. If it works but you don't understand why, then that would be another reason to post again. But if you don't follow the existing advice that's documented as working correctly, speculating about other approaches is simply wasted effort. You might also look at the NSLock or NSConditionLock class, as they may be closer to what you're trying to do. And again, follow the examples in Threading Programming Guide. -- GG ___ 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
Initialising NSMutableArray
I've subclassed an NSMutableArray, and I want it to be initialised with some objects already in place. So I did this: - (id) init { self = [super init]; if (self != nil) { for( int i = 0; i 3; i++ ) [self addObject:[[[myClass alloc] init] autorelease]]; } return self; } But this produces an NSInvalidArgumentException, with the message: [NSMutableArray addObject:]: method only defined for abstract class. I suspect I'm missing something simple here. dkj ___ 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: Best 'Cocoa' File Preview
Thanks Julien, I knew there was something I was misinterpreting, always is! On Jul 13, 2009, at 7:38 AM, Julien Jalon wrote: On Monday, July 13, 2009, David Blanton aired...@tularosa.net wrote: Is it not the case that the UTI is defined in the info.plist CFBundleDocumentTypes? (which I have done). Nope, CFBundleDocumentTypes associates your type to the plugin. You should use UTExportedTypes or UTImportedTypes look for declaring UTI in info.plist in google, you'll find exactly what you need. -- Julien ___ 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
[iPhone] Network connection between 2 iPhones
Hi all... I am new to network programming...so please bear with me... I am trying to program the following functionalities into my app. 1. When my app is running...it can RECEIVE network data from ANOTHER iPHONE through the network. 2. When my app is running...it can RECEIVE network data to ANOTHER IPHONE through the network. Can you please point me in the right direction? Documentations to read? tutorials on the web? or please share your experience... Thank you in advance... James ___ 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: Initialising NSMutableArray
On Jul 13, 2009, at 11:44 AM, DKJ wrote: I've subclassed an NSMutableArray, and I want it to be initialised with some objects already in place. So I did this: ... I suspect I'm missing something simple here. Yes: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/nsmutablearray_Class/Reference/Reference.html NSArray and NSMutableArray are part of a class cluster, so arrays are not actual instances of the NSArray or NSMutableArray classes but of one of their private subclasses. Subclassing is fraught with many angry, fire-breathing, treasure- grubbing dragons and as such is *not* recommended. Especially if you're only trying to get a mutable array populated with a single object. What's wrong with [[NSMutableArray arrayWithObject:[[MyClass alloc] init]]; ? Create a convenience method somewhere in your project such as - mutableArrayWithMyClass that contains the above and you're done. No dragons. -- I.S. ___ 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: [iPhone] Network connection between 2 iPhones
You should look at GameKit.framework - this new API in iPhone OS 3.0 allows simple setup of bluetooth connections between devices for data send/receive. http://developer.apple.com/iphone/library/navigation/Frameworks/CocoaTouch/GameKit/index.html Luke On Jul 13, 2009, at 8:47 AM, James Lin wrote: Hi all... I am new to network programming...so please bear with me... I am trying to program the following functionalities into my app. 1. When my app is running...it can RECEIVE network data from ANOTHER iPHONE through the network. 2. When my app is running...it can RECEIVE network data to ANOTHER IPHONE through the network. Can you please point me in the right direction? Documentations to read? tutorials on the web? or please share your experience... Thank you in advance... James ___ 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/luketheh%40apple.com This email sent to luket...@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
Re: Initialising NSMutableArray
NSMutableArray (and most/all of the collection classes) is an abstract class that can't be usefully sub-classed. The object returned by [NSMutableArray array] is actually a subclass of NSMutableArray. Your best approach is probably to check out categories which can be used to add methods to any existing class. David W. Berry d...@greenwing.com On Jul 13, 2009, at 10:44 AM, DKJ wrote: I've subclassed an NSMutableArray, and I want it to be initialised with some objects already in place. So I did this: - (id) init { self = [super init]; if (self != nil) { for( int i = 0; i 3; i++ ) [self addObject:[[[myClass alloc] init] autorelease]]; } return self; } But this produces an NSInvalidArgumentException, with the message: [NSMutableArray addObject:]: method only defined for abstract class. I suspect I'm missing something simple here. dkj ___ 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/dwb%40greenwing.com This email sent to d...@greenwing.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
Re: [iPhone] Network connection between 2 iPhones
On Jul 13, 2009, at 11:47 AM, James Lin wrote: 2. When my app is running...it can RECEIVE network data to ANOTHER IPHONE through the network. I'm going to assume this is a typo, otherwise you're going to have a difficult time achieving this goal. :-) Can you please point me in the right direction? Documentations to read? tutorials on the web? or please share your experience... Since your question is general (I'm assuming you mean how do I send and receive), the answer is general as well: http://developer.apple.com/iphone/library/navigation/Topics/NetworkingInternet/index.html https://developer.apple.com/iphone/library/codinghowtos/NetworkingAndInternet/index.html -- I.S. ___ 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: [iPhone] Network connection between 2 iPhones
On Jul 13, 2009, at 11:51 AM, Luke the Hiesterman wrote: You should look at GameKit.framework - this new API in iPhone OS 3.0 allows simple setup of bluetooth connections between devices for data send/receive. Ah, you're right, it's GameKit that has the easy peer-to-peer connectivity goodies. -- I.S. ___ 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: Initialising NSMutableArray
What's wrong with [[NSMutableArray arrayWithObject:[[MyClass alloc] init]]; ? The array retains it, so [NSMutableArray arrayWithObject:[[[MyClass alloc] init] autorelease]]; would be better. HTH 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
Re: Initialising NSMutableArray
On Jul 13, 2009, at 12:02 PM, Gideon King wrote: The array retains it, so [NSMutableArray arrayWithObject:[[[MyClass alloc] init] autorelease]]; would be better. Yes, I saw that after I'd sent it but didn't think it worth another e-mail. It's fine if you're using GC . :-D -- I.S. ___ 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: [iPhone] Network connection between 2 iPhones
I did a quick scan of the GameKit programming guide... Just to be sure...does it only work with bluetooth? What if i need connection over the internet? The game kit guide says It does notcover the design and implementation of networked games or applications Thank you again... James On 2009/7/13, at 下午 11:56, I. Savant wrote: On Jul 13, 2009, at 11:51 AM, Luke the Hiesterman wrote: You should look at GameKit.framework - this new API in iPhone OS 3.0 allows simple setup of bluetooth connections between devices for data send/receive. Ah, you're right, it's GameKit that has the easy peer-to-peer connectivity goodies. -- I.S. ___ 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/jamesclin827%40gmail.com This email sent to jamesclin...@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
Re: [iPhone] Network connection between 2 iPhones
GKSession, the connectivity layer, only works with bluetooth. The framework also includes GKVoiceChat which does work over the internet. Luke On Jul 13, 2009, at 9:06 AM, James Lin wrote: I did a quick scan of the GameKit programming guide... Just to be sure...does it only work with bluetooth? What if i need connection over the internet? The game kit guide says It does notcover the design and implementation of networked games or applications Thank you again... James On 2009/7/13, at 下午 11:56, I. Savant wrote: On Jul 13, 2009, at 11:51 AM, Luke the Hiesterman wrote: You should look at GameKit.framework - this new API in iPhone OS 3.0 allows simple setup of bluetooth connections between devices for data send/receive. Ah, you're right, it's GameKit that has the easy peer-to-peer connectivity goodies. -- I.S. ___ 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/jamesclin827%40gmail.com This email sent to jamesclin...@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
Re: [iPhone] Network connection between 2 iPhones
yes this really was rather too vague a question and if you don't have some of the basics of networking understood you're going to have a tough time. There are classes in the OS to deal with various types of network transfer, most of the NS* ones are reasonably high level, at the very bottom you have CFSocket which will do anything you like but needs an understanding of sockets. The GameKit APIs will let you have a quick bluetooth connection between two or more devices and is actually darned well designed for startup and teardown and quick opaque data transfer, if you want more generic client-server you have more work to do, including finding a method for telling device B what the IP address of device A is, that's tough. Can you possibly narrow down what you're trying to do? Is it bluetooth (gamekit), is it internet? Do you have a central server to talk to, are you talking any high level protocols like HTTP which you can use the higher level APIs for or are you raw data on a socket? On Jul 13, 2009, at 11:52 PM, I. Savant wrote: On Jul 13, 2009, at 11:47 AM, James Lin wrote: 2. When my app is running...it can RECEIVE network data to ANOTHER IPHONE through the network. I'm going to assume this is a typo, otherwise you're going to have a difficult time achieving this goal. :-) Can you please point me in the right direction? Documentations to read? tutorials on the web? or please share your experience... Since your question is general (I'm assuming you mean how do I send and receive), the answer is general as well: http://developer.apple.com/iphone/library/navigation/Topics/NetworkingInternet/index.html https://developer.apple.com/iphone/library/codinghowtos/NetworkingAndInternet/index.html -- I.S. ___ 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/rols%40rols.org This email sent to r...@rols.org ___ 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: [iPhone] Network connection between 2 iPhones
the usage scenario... I want my app to obtain another iPhone(also running my app)'s IP address from a server. After that, my app on my iPhone can send data to the other iPhone. This means my app on another iPhone has to be waiting for this network traffic to arrive. How can this be done? Thank you again in advance... James On 2009/7/14, at 上午 12:11, Roland King wrote: yes this really was rather too vague a question and if you don't have some of the basics of networking understood you're going to have a tough time. There are classes in the OS to deal with various types of network transfer, most of the NS* ones are reasonably high level, at the very bottom you have CFSocket which will do anything you like but needs an understanding of sockets. The GameKit APIs will let you have a quick bluetooth connection between two or more devices and is actually darned well designed for startup and teardown and quick opaque data transfer, if you want more generic client-server you have more work to do, including finding a method for telling device B what the IP address of device A is, that's tough. Can you possibly narrow down what you're trying to do? Is it bluetooth (gamekit), is it internet? Do you have a central server to talk to, are you talking any high level protocols like HTTP which you can use the higher level APIs for or are you raw data on a socket? On Jul 13, 2009, at 11:52 PM, I. Savant wrote: On Jul 13, 2009, at 11:47 AM, James Lin wrote: 2. When my app is running...it can RECEIVE network data to ANOTHER IPHONE through the network. I'm going to assume this is a typo, otherwise you're going to have a difficult time achieving this goal. :-) Can you please point me in the right direction? Documentations to read? tutorials on the web? or please share your experience... Since your question is general (I'm assuming you mean how do I send and receive), the answer is general as well: http://developer.apple.com/iphone/library/navigation/Topics/NetworkingInternet/index.html https://developer.apple.com/iphone/library/codinghowtos/NetworkingAndInternet/index.html -- I.S. ___ 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/rols%40rols.org This email sent to r...@rols.org ___ 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: [iPhone] Network connection between 2 iPhones
On Jul 13, 2009, at 10:06 AM, James Lin wrote: What if i need connection over the internet? The game kit guide says It does notcover the design and implementation of networked games or applications I suggest you pick up a book on socket programming. I first learned it by reading The Pocket Guide to TCP/IP Sockets, ISBN 1-55860-686-6. I have no idea if it's still in print, but there are plenty more out there like it. You'll also need to decide between using TCP and UDP for your program, and if you don't know the difference between them, then you'll need to read about that as well. Nick Zitzmann http://www.chronosnet.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
Re: [iPhone] Network connection between 2 iPhones
On Jul 13, 2009, at 11:22 AM, James Lin wrote: the usage scenario... I want my app to obtain another iPhone(also running my app)'s IP address from a server. After that, my app on my iPhone can send data to the other iPhone. This means my app on another iPhone has to be waiting for this network traffic to arrive. How can this be done? In general, this will only work if the two phones are on the same local network (such as on the wifi). If that's the case, you can just use Bonjour for discovery and not even need a remote server. Otherwise, for example, if the two devices are using 3G to connect to the internet, even if they are set up to accept connections, the cell network NAT will disallow incoming connections. More complicated approaches (google tcp hole punching or NAT Traversal) are needed for that (and I'm not sure that those techniques will work across cell networks). You can, however, have both devices connect to the same remote server, and have it forward packets between them, but that approach does not scale well. You're really going to have to do some more research on networking and peer-to-peer connections to understand the ramifications of trying to have one random device talk to another random device. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art ___ 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: Initialising NSMutableArray
On Jul 13, 2009, at 08:49, I. Savant wrote: Subclassing is fraught with many angry, fire-breathing, treasure- grubbing dragons and as such is *not* recommended. On Jul 13, 2009, at 08:51, David W. Berry wrote: NSMutableArray (and most/all of the collection classes) is an abstract class that can't be usefully sub-classed. The object returned by [NSMutableArray array] is actually a subclass of NSMutableArray. As someone who's been guilty of making statements like these in the past, I just want to say : it ain't so. Subclassing NSArray is pretty easy (there are 5 primitive methods to override and you're done). What you *don't* get for free from subclassing is an internal storage mechanism -- you have to invent that for yourself (usually by putting a real NSArray instance variable in your subclass :) ). You also need a pretty clear understanding of how class clusters work, and that's where confusion can set in. The OP didn't have a clear understanding, and that led to his problem. For the record, too, [NSMutableArray array] will normally return an object of the same concrete class as [NSArray array]. In Apple's implementation, they're the same thing, with the mutability enforced at run time. That's an implementation detail, of course, but it's worthwhile being aware of it. ___ 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: NSError in NSDocument readFromURL
On Jul 13, 2009, at 06:52, I. Savant wrote: If not successful, the method returns nil after setting outError to point to an NSError that encapsulates the reason why the document could not be instantiated. Operative word being an NSError. Funny enough, it ignores your reason and never gives one itself. It just says it could not be opened. :-D I'm tempted to call this an API bug, though, before I file documentation bugs. I would expect it to work as the documentation suggests - if I set an error, display that error, else why the hell are you asking me to supply one? Debate? An NSError's description is supposed to say something like: You can't A because B. Its failure reason is supposed to say B. (yes, the same B that's in the description). Its recovery suggestion is supposed to say You can C instead. There's never any API contract about which of these strings the *caller* of a NSError-returning method is going to use. NSDocumentController seems to me to be within its rights to display its own description, annoying as that may be. As the OP demonstrated (and I didn't realize this before he did), NSDocumentController apparently *will* display the failure reason (The document X could not be opened. B.). So you have a way of customizing the alert, so long as you don't mind the canned part talking about documents being opened. If you don't like it, you have the display-your-own-alert-and-return-cancel alternative. But I agree that this is common enough topic that it should be documented more fully. ___ 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: Initialising NSMutableArray
On Jul 13, 2009, at 12:41 PM, Quincey Morris wrote: What you *don't* get for free from subclassing is an internal storage mechanism -- you have to invent that for yourself (usually by putting a real NSArray instance variable in your subclass :) ). You also need a pretty clear understanding of how class clusters work, and that's where confusion can set in. These two sentences are exactly my point. Perhaps we have differing opinions of what makes an angry, fire-breathing, treasure-grubbing dragon. :-) Perhaps another, more universal analogy that I didn't make up just now: The devil is in the details. What's more (said in an off-list discussion with the OP): It's just not worth it to say give me a mutable array with a single instance of a certain class. -- I.S. ___ 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
Crashes in Framework? Tracking down ghosts.
I'm working on an application which is nearing completion, but I'm getting these strange crashes that look to be deep in the cocoa framework. The thing is, I can't seem to diagnose these crashes, and I can't imagine that such bugs exist in the framework such that they pull down my application so frequently. So, I'm assuming it is something I'm doing. I am using garbage collection, and I'm getting an EXC_BAD_ACCESS error. And at least one crash that pops up every so often is below. It stops on the following line of code of the init method (#6 below) in my PrintView class: NSFont *font = [NSFont fontWithName:@Lucida Grande size:fontSize]; #0 0x931ad644 in CFDictionaryGetValue #1 0x901f4fb8 in TDescriptor::CreateMatchingDescriptorInternal #2 0x901f4e1c in TDescriptor::InitBaseFont #3 0x901f4d94 in TDescriptor::CreateMatchingDescriptor #4 0x921d48ec in __NSFontFactoryWithName #5 0x921d466c in +[NSFont fontWithName:size:] #6 0x0005e2e0 in -[PrintView initWithScopeDeduction:andHelper:andDeductionController:] at PrintView.m:32 #7 0x6a8c in -[MyDocument printOperationWithSettings:error:] at MyDocument.m:441 #8 0x9241bde8 in -[NSDocument _printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo :] #9 0x9241bce0 in -[NSDocument printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo :] #10 0x921f58b8 in -[NSApplication sendAction:to:from:] #11 0x922911d0 in -[NSMenu performActionForItemAtIndex:] #12 0x92290f00 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] #13 0x92290bc8 in -[NSMenu performKeyEquivalent:] #14 0x9228f6ac in -[NSApplication _handleKeyEquivalent:] #15 0x921c5d84 in -[NSApplication sendEvent:] #16 0x92132e44 in -[NSApplication run] #17 0x92103820 in NSApplicationMain #18 0x00015bf8 in main at main.m:13 fontSize is valid. If I look into local variables, I get _name being invalid. But if there is a problem with the name, that would be strange, since it works most of the time. Any ideas as to how I can diagnose this problem? I also have seemingly random crashes of this sort when the open file dialogue is opened. Thanks, ___ 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: Mac10.6 bug? NSAppleScript can't work
If you do not receive any reply to your questions, it is likely due to these things: 1) Be sensitive in choosing where you ask your question. You are likely to be ignored, or written off as a loser, if you: ... • cross- post to too many different newsgroups 2) When selecting a Web forum, newsgroup or mailing list, don't trust the name by itself too far; look for a FAQ or charter to verify your question is on-topic Both quotes from: http://catb.org/esr/faqs/smart-questions.html. That said, the right place for this question is: https://devforums.apple.com/community/mac Alex Am 13.07.2009 um 11:28 schrieb william lee: Hi, I have a problem with Mac 10.6 Cocoa application embed Applescript now. The following code works fine in Mac 10.5, and they are almost come from Apple Tech doc. But they doesn't work in Mac 10.6. My App will launch Mail.app, will create an out going message, but can't set the recipient. And also return a error said: Mail got an error: Can't get outgoing message id 409110912 It seems error happen during tell theMessage line, and 111 pop up as expected. 222 will not be reached. Strangely, the exactly same code will work in AppleScript Editor in both 10.5 and 10.6. Is this a bug in Mac 10.6 or my code error? Does anyone encounter this before? Thanks William L. Part of code--- NSString *scriptSource = @ \ tell application \Mail\ to activate\n \ tell application \Mail\\n \ set theMessage to make new outgoing message with properties {visible:true, subject:\s\, content:\c\} \n \ display dialog \111\\n \ tell theMessage\n \ make new to recipient at end of to recipients with properties {address:\a...@dafd.com\}\n \ end tell\n \ display dialog \222\\n \ end tell; int iRes = NSRunAlertPanel(@scriptSource, scriptSource, @OK, nil, nil); NSDictionary* errors = [NSDictionary dictionary]; NSAppleScript* appleScript = [[NSAppleScript alloc] initWithSource:scriptSource]; if (appleScript != nil) { [appleScript executeAndReturnError: errors]; iRes = NSRunAlertPanel(@errors, [errors valueForKey:@NSAppleScriptErrorMessage], @OK, nil, nil); [appleScript release]; return true; } ___ Do not post admin requests to the list. They will be ignored. Applescript-implementors mailing list (applescript-implement...@lists.apple.com ) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-implementors/below%40mac.com This email sent to be...@mac.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
Re: NSError in NSDocument readFromURL
On Jul 13, 2009, at 12:52 PM, Quincey Morris wrote: As the OP demonstrated (and I didn't realize this before he did), NSDocumentController apparently *will* display the failure reason (The document X could not be opened. B.). So you have a way of customizing the alert, so long as you don't mind the canned part talking about documents being opened. If you don't like it, you have the display-your-own-alert-and-return-cancel alternative. You're absolutely right. Using NSLocalizedFailureReasonErrorKey instead of NSLocalizedDescriptionKey does the right thing. Thanks for the clarification. I learn something new every day. :-) -- I.S. ___ 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: Printing a View
Thanks Matt. You were absolutely correct; the problems I have were in -drawRect:. I'm still trying to track down a problem though, and I'm not sure where it is. I've actually cut it down to some fairly simple code. Here it is: -(NSRect)rectForPage:(NSInteger)pageNumber { // Note the current page currentPage = pageNumber-1; float pHeight = linesPerPage * lineHeight; NSRect returnRect = NSMakeRect(0.0, pHeight * currentPage, pageRect.size.width, pHeight); NSLog(@x-origin: %f, y-origin, %f, height: %f, width: %f, returnRect.origin.x, returnRect.origin.y, returnRect.size.height, returnRect.size.width); return returnRect; } -(void)drawRect:(NSRect)rect { NSRect lineRect; lineRect.origin.y = 0; lineRect.origin.x = pageRect.origin.x; lineRect.size.width = pageRect.size.width; lineRect.size.height = lineHeight; for (NSUInteger i=0; i500; i++) { // Draw line number lineRect.origin.y = (i * lineHeight); NSString *lineString = [NSString stringWithFormat:@%d,i]; [lineString drawInRect:lineRect withAttributes:attributes]; } } Now, this should simply print a line of integers down the left side of the page. It does this for two pages - works perfectly - with lines 0 to 50 on the first page, and 51 to 100 on the second page, divided correctly so there is no splitting of lines and so on. But the rest of the pages are blank, and I can't figure out why. The NSLog from - rectForPage: looks like this: x-origin: 0.00, y-origin, 0.00, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 606.899963, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 1213.799927, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 1820.699951, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 2427.599854, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 3034.499756, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 3641.399902, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 4248.299805, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 4855.199707, height: 606.899963, width: 576.00 x-origin: 0.00, y-origin, 5462.099609, height: 606.899963, width: 576.00 ... so it looks to me as if all the pages are being properly selected. Oh, and if I change the paper size and orientation, similar things happen (but not entirely consistently). So, if I choose landscape, it only prints two pages. But if I choose envelope #10, it prints three pages. Thanks, Darcy Several lines down? Could that be the extra 500 you keep introducing? Really, since what you need to say in rectForPage depends completely on how you draw in drawRect, which you don't show, it's hard to guess from here what rectForPage *should* be (or whether you even need to implement it)... m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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: CAKeyframeAnimation problem
On Jul 12, 2009, at 2:17 PM, David W. Berry wrote: So the jist of it is that I create a subclass of CAKeyframeAnimation that has a sequence of images in it's values property and a sequence of frame durations in the keyTimes property. I can then add the animation to a layer to display and that's where the problem arises. The first time (and only the first time) the animation is played the first few frames don't display (the movies are short, they only consist of 3-12 frames at 15fps) After the first time I play the animation and it fails, I can play the animation just fine. Please file a bug report on this issue. One work around is to animate the contentsRect property instead of contents and use the contentsRect to select a portion of a single image that is assigned to the contents property of the layer. -- David Duncan Apple DTS Animation and Printing ___ 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: Capturing active state
Thanks Rob,That's a good workaround! But, this will not fit into our requirements of our application. As per our requirement, we cannot hide the dock icon. In order to go with your solution, we might have to maintain a daemon process which does just screen capture and gives the captured image to the main application(This app will be visible in dock). Is there any other way to solve this issue or should we go with daemon process approach? Regards, Srinivas On 13-Jul-09, at 6:48 AM, Rob Keniger wrote: On 13/07/2009, at 1:19 AM, Srinivas Prabhu G wrote: But the problem here is, as our application is active, when we read image from the frame buffer states of all other apps look disabled ie. scroller and buttons have greyish shade instead of blue. Similar problem is observed in SonOfGrab Apple sample application. (http://devworld.apple.com/samplecode/SonOfGrab/index.html) Is there any workaround to capture the active state of all the windows in desktop? If you add the key LSUIElement with a boolean value of YES to your Info.plist file, your app will run without deactivating other apps. It will also not have a menu bar or dock icon, however for a screen capture app that is probably an advantage. A simple example: http://keniger.com/stuff/ScreenOverlay.zip (run it from the Finder, not Xcode). -- Rob Keniger ___ 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/srinivasprabhug%40gmail.com This email sent to srinivasprab...@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
IMEI Codes?
Is there any way to get the IMEI code programatically? Or does a device token the only unique identifier able to be generated. Sent from my iPhone ___ 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: Crashes in Framework? Tracking down ghosts.
On Jul 13, 2009, at 09:56, K.Darcy Otto wrote: I'm working on an application which is nearing completion, but I'm getting these strange crashes that look to be deep in the cocoa framework. The thing is, I can't seem to diagnose these crashes, and I can't imagine that such bugs exist in the framework such that they pull down my application so frequently. So, I'm assuming it is something I'm doing. I am using garbage collection, and I'm getting an EXC_BAD_ACCESS error. And at least one crash that pops up every so often is below. It stops on the following line of code of the init method (#6 below) in my PrintView class: NSFont *font = [NSFont fontWithName:@Lucida Grande size:fontSize]; #0 0x931ad644 in CFDictionaryGetValue #1 0x901f4fb8 in TDescriptor::CreateMatchingDescriptorInternal #2 0x901f4e1c in TDescriptor::InitBaseFont #3 0x901f4d94 in TDescriptor::CreateMatchingDescriptor #4 0x921d48ec in __NSFontFactoryWithName #5 0x921d466c in +[NSFont fontWithName:size:] #6 0x0005e2e0 in -[PrintView initWithScopeDeduction:andHelper:andDeductionController:] at PrintView.m:32 #7 0x6a8c in -[MyDocument printOperationWithSettings:error:] at MyDocument.m:441 #8 0x9241bde8 in -[NSDocument _printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo :] #9 0x9241bce0 in -[NSDocument printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo :] #10 0x921f58b8 in -[NSApplication sendAction:to:from:] #11 0x922911d0 in -[NSMenu performActionForItemAtIndex:] #12 0x92290f00 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] #13 0x92290bc8 in -[NSMenu performKeyEquivalent:] #14 0x9228f6ac in -[NSApplication _handleKeyEquivalent:] #15 0x921c5d84 in -[NSApplication sendEvent:] #16 0x92132e44 in -[NSApplication run] #17 0x92103820 in NSApplicationMain #18 0x00015bf8 in main at main.m:13 fontSize is valid. If I look into local variables, I get _name being invalid. But if there is a problem with the name, that would be strange, since it works most of the time. Any ideas as to how I can diagnose this problem? I also have seemingly random crashes of this sort when the open file dialogue is opened. Thanks, What version of Mac OS X are you using? There are a couple of possibilities here ... It may be that you have a corrupt font file. Font handling doesn't seem to be very robust in those circumstances. Do these crashes happen on certain Macs but not others? It *appears* (but take this as hearsay, not fact) that some part of the font mechanism isn't entirely GC compatible, and possibly objects you pass to font routines get garbage collected too early. Are you passing the literal string @Lucida Grande or are you really passing something else? Prior to 10.5.5, GC-apps used to crash frequently in the open/save panels because of a frameworks problem with the preview pane (in a column view, where you can play movies, etc). This was fixed in 10.5.5, but I still get occasional similar random crashes in 10.5.7, usually right after the pane is closed. It is known that these panels don't release their resources correctly under GC, at least in some apparently harmless cases, but clearly there's still a nasty problem lurking somewhere. OTOH, it's not impossible that this is related to a corrupted font file too. That's not much help, but it's likely this isn't caused by anything you're doing wrong. (Unless you are doing something wrong.) ___ 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: Crashes in Framework? Tracking down ghosts.
NSFont *font = [NSFont fontWithName:@Lucida Grande size:fontSize]; One thing to note here. Lucida Grande is not a valid font name. The valid name for the font is LucidaGrande without the space. The font system does return the font you intended (matching against the familyname), but it's slower, pressures the system memory, and might not work consistently across different versions of Mac OS X. Aki On 2009/07/13, at 11:24, Quincey Morris wrote: On Jul 13, 2009, at 09:56, K.Darcy Otto wrote: I'm working on an application which is nearing completion, but I'm getting these strange crashes that look to be deep in the cocoa framework. The thing is, I can't seem to diagnose these crashes, and I can't imagine that such bugs exist in the framework such that they pull down my application so frequently. So, I'm assuming it is something I'm doing. I am using garbage collection, and I'm getting an EXC_BAD_ACCESS error. And at least one crash that pops up every so often is below. It stops on the following line of code of the init method (#6 below) in my PrintView class: NSFont *font = [NSFont fontWithName:@Lucida Grande size:fontSize]; #0 0x931ad644 in CFDictionaryGetValue #1 0x901f4fb8 in TDescriptor::CreateMatchingDescriptorInternal #2 0x901f4e1c in TDescriptor::InitBaseFont #3 0x901f4d94 in TDescriptor::CreateMatchingDescriptor #4 0x921d48ec in __NSFontFactoryWithName #5 0x921d466c in +[NSFont fontWithName:size:] #6 0x0005e2e0 in -[PrintView initWithScopeDeduction:andHelper:andDeductionController:] at PrintView.m:32 #7 0x6a8c in -[MyDocument printOperationWithSettings:error:] at MyDocument.m:441 #8 0x9241bde8 in -[NSDocument _printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo :] #9 0x9241bce0 in -[NSDocument printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo :] #10 0x921f58b8 in -[NSApplication sendAction:to:from:] #11 0x922911d0 in -[NSMenu performActionForItemAtIndex:] #12 0x92290f00 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] #13 0x92290bc8 in -[NSMenu performKeyEquivalent:] #14 0x9228f6ac in -[NSApplication _handleKeyEquivalent:] #15 0x921c5d84 in -[NSApplication sendEvent:] #16 0x92132e44 in -[NSApplication run] #17 0x92103820 in NSApplicationMain #18 0x00015bf8 in main at main.m:13 fontSize is valid. If I look into local variables, I get _name being invalid. But if there is a problem with the name, that would be strange, since it works most of the time. Any ideas as to how I can diagnose this problem? I also have seemingly random crashes of this sort when the open file dialogue is opened. Thanks, What version of Mac OS X are you using? There are a couple of possibilities here ... It may be that you have a corrupt font file. Font handling doesn't seem to be very robust in those circumstances. Do these crashes happen on certain Macs but not others? It *appears* (but take this as hearsay, not fact) that some part of the font mechanism isn't entirely GC compatible, and possibly objects you pass to font routines get garbage collected too early. Are you passing the literal string @Lucida Grande or are you really passing something else? Prior to 10.5.5, GC-apps used to crash frequently in the open/save panels because of a frameworks problem with the preview pane (in a column view, where you can play movies, etc). This was fixed in 10.5.5, but I still get occasional similar random crashes in 10.5.7, usually right after the pane is closed. It is known that these panels don't release their resources correctly under GC, at least in some apparently harmless cases, but clearly there's still a nasty problem lurking somewhere. OTOH, it's not impossible that this is related to a corrupted font file too. That's not much help, but it's likely this isn't caused by anything you're doing wrong. (Unless you are doing something wrong.) ___ 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/aki%40apple.com This email sent to a...@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
Re: Best 'Cocoa' File Preview
Here is my info.plist I am trying to get a callback for files ending in .pes My code still does not break. The breakpoint is orange outlined in blue (?) Please shed some light ... ?xml version=1.0 encoding=UTF-8? !DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd plist version=1.0 dict keyCFBundleDevelopmentRegion/key stringEnglish/string keyUTExportedTypeDeclarations/key array dict keyUTTypeIdentifier/key stringcom.britonleap.pes/string keyUTTypeDescription/key stringBrother/Babylock/Bernina Home Embroidery Format/string /dict /array keyCFBundleExecutable/key string${EXECUTABLE_NAME}/string keyCFBundleIconFile/key string/string keyCFBundleIdentifier/key stringcom.britonleap.qlgenerator.${PRODUCT_NAME:identifier}/string keyCFBundleInfoDictionaryVersion/key string6.0/string keyCFBundleName/key string${PRODUCT_NAME}/string keyCFBundleShortVersionString/key string1/string keyCFBundleVersion/key string1.0/string keyCFPlugInDynamicRegisterFunction/key string/string keyCFPlugInDynamicRegistration/key stringNO/string keyCFPlugInFactories/key dict keyFC6CD5CE-323B-492E-A7EA-3C5387644D5D/key stringQuickLookGeneratorPluginFactory/string /dict keyCFPlugInTypes/key dict key5E2D9680-5022-40FA-B806-43349622E5B9/key array stringFC6CD5CE-323B-492E-A7EA-3C5387644D5D/string /array /dict keyCFPlugInUnloadFunction/key string/string keyQLNeedsToBeRunInMainThread/key false/ keyQLPreviewHeight/key real600/real keyQLPreviewWidth/key integer600/integer keyQLSupportsConcurrentRequests/key false/ keyQLThumbnailMinimumSize/key integer32/integer /dict /plist On Jul 13, 2009, at 7:38 AM, Julien Jalon wrote: On Monday, July 13, 2009, David Blanton aired...@tularosa.net wrote: Is it not the case that the UTI is defined in the info.plist CFBundleDocumentTypes? (which I have done). Nope, CFBundleDocumentTypes associates your type to the plugin. You should use UTExportedTypes or UTImportedTypes look for declaring UTI in info.plist in google, you'll find exactly what you need. -- Julien ___ 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
★★★★ Cocoa project for sale
HoudahStudy 2.0 (aka Ebbinghaus). Study card software. Late alpha / early beta. CoreData, CoreAnimation, GC, properties, … Ebbinghaus 1.0 was freeware 2.0 is a complete rewrite. Not yet released. Inquire via email to pierre.bern...@houdah.com Current build available upon request___ 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: [iPhone] Multi-touch gestures in table views?
2009/7/12, Conrad Taylor conra...@gmail.com: Hi, please this is the cocoa-dev mailing list and this thread belongs in the iPhone Developer Forums. Thanks, -Conrad I'm sorry about that. But the iPhone Developer Forums is a closed forum for the paid iPhone Developers Program. I don't have access there yet (for various valid reasons) and I haven't found any better matching open Apple forum than the coca dev that after all covers the very similar Cocoa frameworks and is read by many people programming both for Mac and iPhone. / Påhl On Sun, Jul 12, 2009 at 12:21 PM, Fritz Anderson fri...@manoverboard.orgwrote: On 12 Jul 2009, at 1:37 PM, Påhl Melin wrote: Is there a way to stop table views interpret multi-finger gestures as single-finger scrolling? I don't know for sure, but my next experiment would be the delaysContentTouches property of UIScrollView (and therefore of UITableView). — F ___ 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/conradwt%40gmail.com This email sent to conra...@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/listor.pm%40gmail.com This email sent to listor...@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
Re: IMEI Codes?
You can get the unique device identifier (UDID) for a device, which is a hash of different hardware identifiers (like the serial number) - look at UIDevice. Its not really clear for what purposes you need the identifier for, though, so whether or not you really need that or something else isn't clear. If you plan to use it in the context of the push notification provider, keep in mind that the UDID and the push device token do not behave in the same ways. The UDID is based on hardware identifiers, so it doesn't ever change for a single device - even if that device is wiped, given to someone else, restored from backup, etc. The device token, on the other hand, does change when the device is wiped. - Bryan On Jul 13, 2009, at 1:17 PM, Rick Langschultz wrote: Is there any way to get the IMEI code programatically? Or does a device token the only unique identifier able to be generated. Sent from my iPhone ___ 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/bryanhenry%40mac.com This email sent to bryanhe...@mac.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
Re: NSError in NSDocument readFromURL
Did someone already open an documentation bug at apple regarding this issue? If not successful, the method returns nil after setting outError to point to an NSError that encapsulates the reason why the document could not be instantiated. Operative word being an NSError. Funny enough, it ignores your reason and never gives one itself. It just says it could not be opened. :-D I'm tempted to call this an API bug, though, before I file documentation bugs. I would expect it to work as the documentation suggests - if I set an error, display that error, else why the hell are you asking me to supply one? Debate? An NSError's description is supposed to say something like: You can't A because B. Its failure reason is supposed to say B. (yes, the same B that's in the description). Its recovery suggestion is supposed to say You can C instead. There's never any API contract about which of these strings the *caller* of a NSError-returning method is going to use. NSDocumentController seems to me to be within its rights to display its own description, annoying as that may be. As the OP demonstrated (and I didn't realize this before he did), NSDocumentController apparently *will* display the failure reason (The document X could not be opened. B.). So you have a way of customizing the alert, so long as you don't mind the canned part talking about documents being opened. If you don't like it, you have the display-your-own-alert-and-return-cancel alternative. But I agree that this is common enough topic that it should be documented more fully. ___ 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: CAKeyframeAnimation problem
The work-around did, indeed, solve the problem I was having with the sequence, they now play correctly from start to stop. If I might prevail upon you with another question, the goal is to trigger a short animation, leaving the last animation frame displayed as a lasting part of the image, right now I have a flicker as the animation is removed and then the underlying view is redrawn with the added image. What's the convenient way to avoid the flickering? David W. Berry d...@greenwing.com 16709 Decker Creek Manor, TX 78653 H: 512 276 1396 M: 512 293 5183 On Jul 13, 2009, at 1:06 PM, David Duncan wrote: On Jul 12, 2009, at 2:17 PM, David W. Berry wrote: So the jist of it is that I create a subclass of CAKeyframeAnimation that has a sequence of images in it's values property and a sequence of frame durations in the keyTimes property. I can then add the animation to a layer to display and that's where the problem arises. The first time (and only the first time) the animation is played the first few frames don't display (the movies are short, they only consist of 3-12 frames at 15fps) After the first time I play the animation and it fails, I can play the animation just fine. Please file a bug report on this issue. One work around is to animate the contentsRect property instead of contents and use the contentsRect to select a portion of a single image that is assigned to the contents property of the layer. -- David Duncan Apple DTS Animation and Printing ___ 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: CAKeyframeAnimation problem
On Jul 13, 2009, at 3:42 PM, David W. Berry wrote: If I might prevail upon you with another question, the goal is to trigger a short animation, leaving the last animation frame displayed as a lasting part of the image, right now I have a flicker as the animation is removed and then the underlying view is redrawn with the added image. What's the convenient way to avoid the flickering? Set the final value of the animation on the layer when you add the animation. You'll want to disable actions when you change the current value of the layer as well. -- David Duncan Apple DTS Animation and Printing ___ 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
AVAudioplayer is skipping -- sounds like a cd skipping
I'm using this basic code to play a sound and it frequently skips at the end, sounded like a cd skipping. I'm playing .caf files at 22500 Hz. Does anyone any experience with this? Thanks! int soundNum= arc4random() % [soundsArray count]; AVAudioPlayer *sound= [soundsArray objectAtIndex:soundNum]; [currentSound stop]; currentSound = nil; currentSound = sound; [currentSound setCurrentTime:0.0]; [currentSound play]; ___ 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: AVAudioplayer is skipping -- sounds like a cd skipping
Please file a bug. Attach a sample app with your audio. Thanks, Luke On Jul 13, 2009, at 3:54 PM, Miles wrote: I'm using this basic code to play a sound and it frequently skips at the end, sounded like a cd skipping. I'm playing .caf files at 22500 Hz. Does anyone any experience with this? Thanks! int soundNum= arc4random() % [soundsArray count]; AVAudioPlayer *sound= [soundsArray objectAtIndex:soundNum]; [currentSound stop]; currentSound = nil; currentSound = sound; [currentSound setCurrentTime:0.0]; [currentSound play]; ___ 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/luketheh%40apple.com This email sent to luket...@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
RE: literal strings - who do they belong to?
be made to behave correctly anyway. For example, you'd never do a thing like this: { NSData *data = [[NSData alloc] initWithBytes:foo length:bar]; const char *bytes = [data bytes]; [data release]; CrashByDoingSomethingWithBytes(bytes); } Why should this sort of thing be expected to work, just because the property in question happens to be an object? Correct, I'd never do that. I know accessing NSData's internal bytes array is definitely something that I wouldn't expect to work - that 'const char *' out the front of -bytes tells me that I don't get to own those bytes. So I wouldn't have done it, nor expected it to work. Apples memory rules are explicit and short, and should never be re-stated because you'll always get it wrong - here's Apple's webpage: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html ... if you need to store a received object as a property in an instance variable, you must retain or copy it. Thus, apparentl doing NSString *s = someobject.somevar; is essentially against the rules. You should always use NSString *s = [[someobject.somevar {retain|copy}] autorelease]; (To my eye, not common sense, but understandable) Quoting Peter Lewis: if you want to keep it, retain/copy it applies, even if you are only going to keep it for the duration of the current method in a local variable. This is something I wasn't completely conscious of. If everyone adhered to that particular rule then it seems there would be no need for the superfluous retain/autorelease in all accessors. However they then go on to say: A received object is normally guaranteed to remain valid within the method it was received in (exceptions include multithreaded applications and some Distributed Objects situations, although you must also take care if you modify the object from which you received the object). That method may also safely return the object to its invoker which touches on one of my favorite sore-points that has been hashed out time and time again in the past, that calling 'release' on an object means modifying it - my example definitely released the object and knew it was doing it. I can certainly visualise a scenario where retrieving property V from object A might actually result in the retrieval of some hidden implementation-specific object B's instance variables which I have no knowledge of. I can't tell what actions I perform on A which might cause B to be dealloc'd and thus invalidate the value of V, even if they didn't seem to modify A. However, the last sentence about the method being able to return the object to its invoker is just bizarre - it glosses over things like 'this method has an autorelease pool', etc. I would have thought that it makes more sense to simply state that you should [[o retain] autorelease] anything you want to return at all levels, rather than implicitly insisting that the bottom level will have done it. If you always obey the if I stored it in a local variable, I must retain it and thus arrange for it to be released, then the only way you could return it to your caller would be from that local and thus it would be legal. So, a method may safely return the object to its invoker either: a) directly.return [someobj foo]; b) indirectly.NSObject *val = [[[someobj foo] retain] autorelease]; return val; Technically those are the only ways you are allowed to retrieve the value then return it and in both cases there is zero change in 'retain count' and the object remains alive as per Apples rules. Jeff Laing je...@spatialinfo.com -- A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over, beginning with a working simple system. -- J Gall. Systemantics: How systems work and how they fail ___ 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: Printing a View
On Mon, 13 Jul 2009 10:07:17 -0700, K. Darcy Otto do...@csusb.edu said: Now, this should simply print a line of integers down the left side of the page. It does this for two pages - works perfectly - with lines 0 to 50 on the first page, and 51 to 100 on the second page, divided correctly so there is no splitting of lines and so on. But the rest of the pages are blank, and I can't figure out why. The NSLog from - Again, you're not providing enough information, but here are some questions to ask yourself. * What's printing is a view. How tall is that view? Is it tall enough to contain 500 lines? * Also: In drawRect:(NSRect)rect, what is rect? Those (and reading the docs) should lead to an aha moment... Also you might like to search the archives. Printing is really easy and you're making it hard for yourself, which is a pity. I've given some possibly useful hints here: http://www.cocoabuilder.com/archive/message/cocoa/2004/8/20/115128 http://www.cocoabuilder.com/archive/message/cocoa/2007/9/13/189212 http://www.cocoabuilder.com/archive/message/cocoa/2006/12/14/175913 http://www.cocoabuilder.com/archive/message/cocoa/2007/4/11/181739 I strongly suggest (as it says in one of those) that at first you completely ignore pagination. Don't implement anything except drawRect! Just create the view and draw it. Create it big enough for what needs to be drawn, and when the system asks you draw what goes in a certain rect, draw what goes in that rect. You will be amazed at how simple it all is. NOW you can start adding finesse if you want to. By the way, if you are implementing rectForPage in order to prevent lines from being split across pages, that is NOT how to do it. See adjustPageHeightNew:. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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
Saving NSArray of custom objects
I've defined my own MyClass and made it conform to the NSCoding protocol by adding methods like this: - (void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeInt:index forKey:@index]; } - (id)initWithCoder:(NSCoder *)decoder { self = [super init]; index = [decoder decodeIntForKey:@index]; return self; } I then put a bunch of these into an NSArray and try to save the array like this: NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:FILE_PATH]; BOOL didIt = [theArray writeToFile:path atomically:NO]; But nothing is saved: didIt = 0. I must be missing a step somewhere. I've been looking at Archives and Serializations Programming Guide for Cocoa, and finding it rather bewildering. A nudge in the right direction would be much appreciated. dkj ___ 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: Saving NSArray of custom objects
Hey dkj - The method -[NSArray writeToFile: atomically:] uses property list serialization, and property lists support a fixed set of types. You want to serialize your NSArray with an NSCoder, like NSKeyedArchiver, and then read it back in with NSKeyedUnarchiver. Take a look at these two methods: -[NSKeyedArchiver archiveRootObject:toFile:] -[NSKeyedUnarchiver unarchiveObjectWithFile:] Good luck - Jon Hess On Jul 13, 2009, at 5:22 PM, DKJ wrote: I've defined my own MyClass and made it conform to the NSCoding protocol by adding methods like this: - (void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeInt:index forKey:@index]; } - (id)initWithCoder:(NSCoder *)decoder { self = [super init]; index = [decoder decodeIntForKey:@index]; return self; } I then put a bunch of these into an NSArray and try to save the array like this: NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:FILE_PATH]; BOOL didIt = [theArray writeToFile:path atomically:NO]; But nothing is saved: didIt = 0. I must be missing a step somewhere. I've been looking at Archives and Serializations Programming Guide for Cocoa, and finding it rather bewildering. A nudge in the right direction would be much appreciated. dkj ___ 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/jhess%40apple.com This email sent to jh...@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
Re: Best 'Cocoa' File Preview
On Jul 13, 2009, at 1:02 PM, David Blanton wrote: Here is my info.plist I am trying to get a callback for files ending in .pes keyUTExportedTypeDeclarations/key array dict keyUTTypeIdentifier/key stringcom.britonleap.pes/string keyUTTypeDescription/key stringBrother/Babylock/Bernina Home Embroidery Format/string /dict /array Compare with the example at http://developer.apple.com/macosx/uniformtypeidentifiers.html which is the first hit on the search that Julien suggested. You're missing a number of key/value pairs, notably UTTypeTagSpecification and UTTypeConformsTo. smime.p7s Description: S/MIME cryptographic 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: literal strings - who do they belong to?
{ NSData *data = [[NSData alloc] initWithBytes:foo length:bar]; const char *bytes = [data bytes]; [data release]; CrashByDoingSomethingWithBytes(bytes); } Why should this sort of thing be expected to work, just because the property in question happens to be an object? A facetious example, because in reality you never know where pointers are coming from when returned from some other method. Why should you ever expect any use of any returned pointer from any object to work? That there are some well known cases doesn't negate the fact that this is quite problematic to assume this universally. Completely impractical, in fact. One could argue that NSData should [[self retain] autorelease] itself in that case. But there are valid performance concerns particularly with NSData, which may be why it doesn't. Certainly it probably didn't do it originally because no one anticipated it would be a problem, not because of any deliberate design choice. http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html ... if you need to store a received object as a property in an instance variable, you must retain or copy it. Thus, apparentl doing NSString *s = someobject.somevar; is essentially against the rules. You should always use NSString *s = [[someobject.somevar {retain|copy}] autorelease]; (To my eye, not common sense, but understandable) Note that it says instance variable, not local variable. It should also so global variable, for completeness; anything outside the scope of the current function or method. The general assumption in Cocoa is that the received object is valid for the rest of your function, which is in fact a simplification (of it being valid 'til the next autorelease pool or next destructive change, the latter part being the concession to reality rather than an intended contract). In any case, if you want to take it as aggressively as you've suggested, then you can try that, but it's still wrong; by the time you get the result it may already have been released. This is the entire point behind autorelease pools; to allow any object to return any other object to any other code without the nightmares. As I said in my original reply, you just can't live happily in Cocoa if you don't accept this, and follow it. That many objects don't follow, or correctly follow, this approach is a sad excuse not to try to do so now and in future. There will always be exceptional cases, but they can remain exceptional. And many can be fixed. These sorts of issues can be huge time wasters, I know all too well. Which is why I'm so strongly advocating you to follow the policy I suggested. There's also a high cost, in CPU cycles and memory, to retain/ [auto]release in such an excessively defensive way. And have fun using Object Alloc to find real problems once you've added these superfluous retain/release/autoreleases to every return value in your entire program. A received object is normally guaranteed to remain valid within the method it was received in (exceptions include multithreaded applications and some Distributed Objects situations, although you must also take care if you modify the object from which you received the object). That method may also safely return the object to its invoker This is written quite conservatively to address the fact that a lot of code is very poorly written in this regard. But again, bad history doesn't justify bad future. @propertys make it nice and easy to avoid these issues by doing it right to begin with; being atomic. There are certainly valid scenarios where you can justify opting out of this, but only a few. And you should certainly document them very carefully. Or better yet, use an alternate but still safe pattern, such as atomic-retain/copy-return). However, the last sentence about the method being able to return the object to its invoker is just bizarre - it glosses over things like 'this method has an autorelease pool', etc. I would have thought that it makes more sense to simply state that you should [[o retain] autorelease] anything you want to return at all levels, rather than implicitly insisting that the bottom level will have done it. That document is written at a very introductory level and assumes if you're conscious of autorelease pools, you're aware of their caveats. Beyond that, what you've suggested is overly defensive again. Sometimes necessary for complex control flow (e.g. if you yourself return the raw bytes of an NSData, or if you are indeed escaping from the topmost autorelease pool), but the cost of all those autoreleases will rapidly add up to something significant in many programs. Getting it right at the originator is simpler, and more efficient - for all you know any given method returns a constant (or any other kind
Re: literal strings - who do they belong to?
On Jul 13, 2009, at 7:42 PM, Wade Tregaskis wrote: There's also a high cost, in CPU cycles and memory, to retain/ [auto]release in such an excessively defensive way. And have fun using Object Alloc to find real problems once you've added these superfluous retain/release/autoreleases to every return value in your entire program. But wouldn't adding those retain/autoreleases to every accessor in your entire program have the same effect? Charles ___ 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: literal strings - who do they belong to?
There's also a high cost, in CPU cycles and memory, to retain/ [auto]release in such an excessively defensive way. And have fun using Object Alloc to find real problems once you've added these superfluous retain/release/autoreleases to every return value in your entire program. But wouldn't adding those retain/autoreleases to every accessor in your entire program have the same effect? Perhaps to an extent, if the object in question lives a long time relative to the number of gets of it. But in any case, the same object may be passed down a very long callstack, so the difference could be between a single retain]autorelease] and a thousand of them. It's still easier to interpret in tools like Object Alloc, though - you can clearly see the retain]autorelease] for each getter scattered throughout other uses. The periods you're most interested in are likely to be between calls to the getter (on the same thread, at least), and so much less noisy. Wade ___ 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: [iPhone] Network connection between 2 iPhones
Have a look at the Witap code sample. It finds other iPhones over Bonjour and connects sets up a socket connection (I believe it uses CFNetwork, but I don't have it handy right now). If you need more info, look at the CFNetwork programming guide - CFNetwork isn't that bad, and the guide contains enough sample code to get you started. Hope that helps, Hank On Jul 13, 2009, at 12:22 PM, James Lin wrote: the usage scenario... I want my app to obtain another iPhone(also running my app)'s IP address from a server. After that, my app on my iPhone can send data to the other iPhone. This means my app on another iPhone has to be waiting for this network traffic to arrive. How can this be done? Thank you again in advance... James On 2009/7/14, at 上午 12:11, Roland King wrote: yes this really was rather too vague a question and if you don't have some of the basics of networking understood you're going to have a tough time. There are classes in the OS to deal with various types of network transfer, most of the NS* ones are reasonably high level, at the very bottom you have CFSocket which will do anything you like but needs an understanding of sockets. The GameKit APIs will let you have a quick bluetooth connection between two or more devices and is actually darned well designed for startup and teardown and quick opaque data transfer, if you want more generic client-server you have more work to do, including finding a method for telling device B what the IP address of device A is, that's tough. Can you possibly narrow down what you're trying to do? Is it bluetooth (gamekit), is it internet? Do you have a central server to talk to, are you talking any high level protocols like HTTP which you can use the higher level APIs for or are you raw data on a socket? On Jul 13, 2009, at 11:52 PM, I. Savant wrote: On Jul 13, 2009, at 11:47 AM, James Lin wrote: 2. When my app is running...it can RECEIVE network data to ANOTHER IPHONE through the network. I'm going to assume this is a typo, otherwise you're going to have a difficult time achieving this goal. :-) Can you please point me in the right direction? Documentations to read? tutorials on the web? or please share your experience... Since your question is general (I'm assuming you mean how do I send and receive), the answer is general as well: http://developer.apple.com/iphone/library/navigation/Topics/NetworkingInternet/index.html https://developer.apple.com/iphone/library/codinghowtos/NetworkingAndInternet/index.html -- I.S. ___ 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/rols%40rols.org This email sent to r...@rols.org ___ 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/hank.list %40runbox.com This email sent to hank.l...@runbox.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
Re: Best 'Cocoa' File Preview
Maybe I should reformulate my question. I want the Finder to call my QLGenerator whenever it sees a file of type '.pes'. Can someone show me the required info.plist entries? This does not get my generator called: keyUTExportedTypeDeclarations/key array dict keyUTTypeIdentifier/key stringcom.pes.britonleap/string keyUTTypeDescription/key stringBrother/Babylock/Bernina Home Embroidery Format/string keyUTTypeConformsTo/key array stringpublic.item/string /array keyUTTypeTagSpecification/key dict keypublic.filename-extension/key array stringpes/string /array /dict /dict /array Furthermore why so convoluted and difficult? I should be able to say call me for files of type'.pes' and be done with it. Any help is appreciated. On Jul 13, 2009, at 6:33 PM, Adam R. Maxwell wrote: On Jul 13, 2009, at 1:02 PM, David Blanton wrote: Here is my info.plist I am trying to get a callback for files ending in .pes keyUTExportedTypeDeclarations/key array dict keyUTTypeIdentifier/key stringcom.britonleap.pes/string keyUTTypeDescription/key stringBrother/Babylock/Bernina Home Embroidery Format/string /dict /array Compare with the example at http://developer.apple.com/macosx/uniformtypeidentifiers.html which is the first hit on the search that Julien suggested. You're missing a number of key/value pairs, notably UTTypeTagSpecification and UTTypeConformsTo. ___ 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: Best 'Cocoa' File Preview
On 14/07/2009, at 11:34 AM, David Blanton wrote: Furthermore why so convoluted and difficult? I should be able to say call me for files of type'.pes' and be done with it. Any help is appreciated. The system has to consider the more general situation - what if the type were '.txt'? Approaching the problem sideways - did you consider just using the embedded JPG/PDF preview images? Setting your file up as a package is really easy (much easier than dealing with UTIs) and adding the images is likewise very straightforward. Maybe I'm just lazy but I'll pick the easy option (i.e. get the OS to deal with it rather than write my own generator) every time. --Graham ___ 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: Best 'Cocoa' File Preview
On Jul 13, 2009, at 6:34 PM, David Blanton wrote: Maybe I should reformulate my question. I want the Finder to call my QLGenerator whenever it sees a file of type '.pes'. Can someone show me the required info.plist entries? You need to do two things: 1) declare your type to map .pes files to com.pes.britonleap 2) declare your bundle as QL plugin for com.pes.britonleap If your earlier post had the entire plist, it looks like you're missing CFBundleDocumentTypes, so there's nothing to associate your plugin with com.pes.britonleap files. Here's a complete example from one of my plugins: http://code.google.com/p/mactlmgr/source/browse/DVI-qlgenerator/Info.plist Check `mdls somefile.pes` in Terminal to make sure kMDItemContentType matches your UTI. smime.p7s Description: S/MIME cryptographic 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: Best 'Cocoa' File Preview
These are not my files. just know (intellectual property) how to read and write them. There are approx 18 formats that will ultimately be supported by by generator. On Jul 13, 2009, at 7:48 PM, Graham Cox wrote: On 14/07/2009, at 11:34 AM, David Blanton wrote: Furthermore why so convoluted and difficult? I should be able to say call me for files of type'.pes' and be done with it. Any help is appreciated. The system has to consider the more general situation - what if the type were '.txt'? Approaching the problem sideways - did you consider just using the embedded JPG/PDF preview images? Setting your file up as a package is really easy (much easier than dealing with UTIs) and adding the images is likewise very straightforward. Maybe I'm just lazy but I'll pick the easy option (i.e. get the OS to deal with it rather than write my own generator) every time. --Graham ___ 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
Networking
I'm not sure how to begin this, so I'll start off with what I have. What I have: Device A and Device B. Device A is connected to the internet (at address The Address, and has port The Port routed to it for instance) Device B is also connected to the internet, but is not on the same local network as Device A. What I want: A custom written server on Device A that listens on The Port for a device to connect. It expects to be sent an NSData object and will be expected to return another NSData object. Device B should be able to, through a blocking method (or background in a thread), get an NSData object returned by Device A after giving it another NSData object. (for example, Device B asks Device A Do I have messages? and gets Yes, you have two in response) What I've tried and/or cannot use: I cannot use Distributed Objects. Although this would make this incredibly easy, Device B is an iPhone and does not support distributed objects. I've tried setting up an HTTP server using NSSocketPort and NSFileHandle's acceptConnectionInBackgroundAndNotify method; however, I seem to be unable to get the client (regardless of platform) to be able to send an arbitrary data package to it and get one in return. So, my question is, does anybody know of any other ways - or good beginner's guides - to networking in situations like this? ___ 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: Best 'Cocoa' File Preview
Ok Adam. I took your example and got this: http://highrolls.net/Samples/Info.plist Please comment, as my qlgen is not called. And I did mdls and got this: http://highrolls.net/Samples/mdls.txt which shows a different kMDItemContentType. Am I even getting close? On Jul 13, 2009, at 7:50 PM, Adam R. Maxwell wrote: On Jul 13, 2009, at 6:34 PM, David Blanton wrote: Maybe I should reformulate my question. I want the Finder to call my QLGenerator whenever it sees a file of type '.pes'. Can someone show me the required info.plist entries? You need to do two things: 1) declare your type to map .pes files to com.pes.britonleap 2) declare your bundle as QL plugin for com.pes.britonleap If your earlier post had the entire plist, it looks like you're missing CFBundleDocumentTypes, so there's nothing to associate your plugin with com.pes.britonleap files. Here's a complete example from one of my plugins: http://code.google.com/p/mactlmgr/source/browse/DVI-qlgenerator/Info.plist Check `mdls somefile.pes` in Terminal to make sure kMDItemContentType matches your UTI. ___ 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: literal strings - who do they belong to?
On 14/07/2009, at 7:34 , Jeff Laing wrote: Thus, apparentl doing NSString *s = someobject.somevar; is essentially against the rules. You should always use NSString *s = [[someobject.somevar {retain|copy}] autorelease]; No, this is unnecessary. You do not need to do this unless you intend to store it past when you return, or unless you intend to modify (including, as you point out, release) someobject (directly or indirectly). There is also the issue that you must be certain that anything you call, and anything called by your callee if you return it cannot modify/release someobject - at some point it may be easier to use the retain/autorelease idiom than prove that nothing can modify someobject, but often it is not necessary. On 14/07/2009, at 8:42 , Wade Tregaskis wrote: Whether they're cached or singletons or whatever else, they must obey the policy that they'll stick around 'til the next flush of the current thread's current autorelease pool. You just can't safely handle the memory management otherwise, especially in multithreaded cases. My assertion there was ambiguous, it's true; I meant that you must do so if you want to retain your sanity, not that this is what everyone in fact does, nor has done to date. As we've seen already through examples. This is exactly the misconception that needs to be avoided. Here is a trivial counter example: id obj = [dict objectForKey:@whatever]; [dict release]; NSLog( @this will crash %@, id ); No autorelease pool, no remaining valid until the current autorelease pool is flushed. And if you extrapolate this example further to the case where [dict release] is called on another thread, you're in a real pickle. Ideally, objectForKey: would retain]autorelease]. This multithreading argument is completely irrelevant. If your code is not thread safe, that is a completely independent issue which atomic and retain/autorelease will not solve! Consider the case where one thread releases dict and the other thread calls [dict objectForKey:@whatever] as above. Even if objectForKey retain/autoreleas and even if objectForKey is atomic, it is insufficient to defend you from multi threading issues. Imagine your code is interrupted immediately on the instruction that calls objectForKey and then the other thread that calls dict release is executed. You still crash. Being thread safe is a whole different can of worms and has almost nothing to do with the memory management rules. It is not optimising away the return [[foo retain] autorelease], which is explicitly allowed in the rules (That method may also safely return the object to its invoker), it is assuming something about the lifetime of the object you don't own that gets people in to trouble. As I stated and have reiterated here, coding so defensively is just plain bad for your mental well-being. We have to live with the imperfect world, but the point of this is what you can do in your code, which is to say: you can do it right, instead. Don't stress so much over the edge cases; learn them and work around them, and don't propagate them. There is no need to code defensively, there is a need to code to the rules: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html * Assume you own an object if and only if the method is named alloc/ new/copy/retain. Otherwise: * Do *not* assume the return value is autoreleased * Do *not* refer to the retainCount * If you are going to store it or if you are going to modify/release the source object, you need to take ownership of it (with alloc/new/ copy/retain). * You can safely return it, assuming the returned code will not modify the source object And if you want to write thread safe code, then you need to write thread safe code, not rely on atomic or memory management rules, neither of which will help you appreciably. Enjoy, Peter. -- Clipboard Switching and Macros with Keyboard Maestro Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac http://www.stairways.com/ http://download.stairways.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
Re: Best 'Cocoa' File Preview
Arrggg! Had a misspelling in my -t parameters - break point being hit! Now to add more than on file type. Thanks a bunch to all but I'll be back! db On Jul 13, 2009, at 7:50 PM, Adam R. Maxwell wrote: On Jul 13, 2009, at 6:34 PM, David Blanton wrote: Maybe I should reformulate my question. I want the Finder to call my QLGenerator whenever it sees a file of type '.pes'. Can someone show me the required info.plist entries? You need to do two things: 1) declare your type to map .pes files to com.pes.britonleap 2) declare your bundle as QL plugin for com.pes.britonleap If your earlier post had the entire plist, it looks like you're missing CFBundleDocumentTypes, so there's nothing to associate your plugin with com.pes.britonleap files. Here's a complete example from one of my plugins: http://code.google.com/p/mactlmgr/source/browse/DVI-qlgenerator/Info.plist Check `mdls somefile.pes` in Terminal to make sure kMDItemContentType matches your UTI. ___ 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: Window Resize with Animator Proxy: Window Contents Jump Around
On 13/07/2009, at 19:08 , Marc Liyanage wrote: I am trying to resize a window with an animation using the NSAnimatablePropertyContainer animator proxy mechanism. The views have the Wants CA Layer option set in IB. Its ridiculously painful isn't it? One thing that may trip you up is auto resizing. Consider disabling it or making sure it is behaving properly. Also, I've found generally that using custom flipped views works better. this gives a top left co-ordinate system and avoids a lot of jittering. @implementation FlippedView - (BOOL)isFlipped { return YES; } - (void)awakeFromNib; { for ( NSView *v in self.subviews ) { NSRect frame = v.frame; frame.origin.y = NSMaxY(self.bounds) - NSMaxY(frame); v.frame = frame; v.autoresizingMask = v.autoresizingMask ^ (NSViewMinYMargin| NSViewMaxYMargin); } } @end Further, I never got layer backing to work properly if there are any scroll bars involved, and there are probably other cases that simply didn't work well (at least in Leopard). It also works if I don’t enable the CA layer backing in IB, but I need that because I am going to fade a subview at the same time as I resize the window. Without CA layers I can only hide and show the subview with a hard transition, but I want to fade it. Check out MGViewAnimation from Matt Gemmell http://mattgemmell.com/2006/11/13/mgviewanimation . I use a heavily hacked version for the next version of Keyboard Maestro to get animating/fading views and it works quite well. Enjoy, Peter. -- Clipboard Switching and Macros with Keyboard Maestro Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac http://www.stairways.com/ http://download.stairways.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
Re: literal strings - who do they belong to?
id obj = [dict objectForKey:@whatever]; [dict release]; NSLog( @this will crash %@, id ); And if you extrapolate this example further to the case where [dict release] is called on another thread, you're in a real pickle. Ideally, objectForKey: would retain]autorelease]. This multithreading argument is completely irrelevant. If your code is not thread safe, that is a completely independent issue which atomic and retain/autorelease will not solve! Fair to say. I contemplated expanding on this point previously, but declined by way of laziness. You sods proffer no mercy, do you? :P Atomic properties (nor autorelease pools) are definitely not a panacea for multithreading. That said, bear in mind what my suggestion does buy you: if NSDictionary did atomically retain]autorelease] from objectForKey:, then it would be thread-safe to mutate the dictionary. If this is just some big global, say - some kind of cache or hash table or whatever else - it may well be a totally appropriate level to implement that thread safety. If, however, as Peter points out, it's just some little dictionary buried in some bigger class, then it's likely not the level you want to resolve mutual exclusion at. But it doesn't necessarily hurt; maybe your app will still draw things out of order, but at least it doesn't crash. Furthermore, in the example above 'dict' should be owned by the execution function at that time, since it's either explicitly owned, or was returned to it via retain]autorelease]. See how it recurses? If everyone plays by these rules, life gets a whole lot simpler. Keep in mind the dictionary case is just an example, not to be taken too literally for the purposes of this discussion. The warning I've tempered this advice with throughout is with regards to performance. We all cut corners sometimes in the name of necessary practicality. Otherwise we'd all be programming in Lisp instead of this clumsy C stuff. And you should have seen some of the internal discussions over whether @property should be atomic by default or not. But the performance mantra applies as always: correct first, optimal later (though, please, not too much later :) ). Wade ___ 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: ???? Cocoa project for sale
On Mon, 13 Jul 2009 22:49:28 +0200, Houdah - ML Pierre Bernard pierre.bern...@lists.houdah.com said: HoudahStudy 2.0 (aka Ebbinghaus). Study card software. Late alpha / early beta. CoreData, CoreAnimation, GC, properties, Ebbinghaus 1.0 was freeware 2.0 is a complete rewrite. Not yet released. Inquire via email to pierre.bern...@houdah.com Current build available upon request Just open source it if you don't want to deal with it any more. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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: ???? Cocoa project for sale
On 14/07/2009, at 1:48 PM, Matt Neuburg wrote: HoudahStudy 2.0 (aka Ebbinghaus). Study card software. Late alpha / early beta. CoreData, CoreAnimation, GC, properties, ∑ Ebbinghaus 1.0 was freeware 2.0 is a complete rewrite. Not yet released. Inquire via email to pierre.bern...@houdah.com Current build available upon request Just open source it if you don't want to deal with it any more. Indeed - if unfinished projects were actually worth anything I could probably have made a fortune by now ;-) --Graham___ 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
spaghetti code with core data and multiple views
Hi, I am busy writing my first app using objective-c, cocoa, xcode, etc. It is basically an app that will allow the user to compile meta data from several sources, select the bits he wants, and then write that meta data to the movie file. Think MetaX with more sources. My main overall problem is: How do I avoid spaghetti code with multiple views who need to interact with core data and each other? I am a CS student, so I have been taught a lot of best-practices when it comes to architecture, and abstracting code. I have been trying my best to stay true to these principles, and have so far carved up my app and it's code into several class and views. This is the rough outline of the architecture at the moment: *Started with a Core Data Application *Removed the window from the default MainMenu.xib *Added a new class called MainWindowController who was a MainWindow.xib file (main purpose for this was to avoid messing about with the default AppDelegate as it had so much code in there already) *The AppDelegate now instantiates the MainWindowController in awakeFromNib *MainWindowController holds a toolbar, a bunch of other components, and an NSTabView which it passes on to two other ViewControllers: **otherSourcesTagsViewController creates a new tab in the NSTabView and adds it own view to it. It has a bunch of nspopup button fields where the user can select from predefined information fetched from the core data repository **currentTagsViewController creates a new tab in the NSTabView and adds it own view to it. It has a bunch of text entry fields where the user can manually edit the tagged information that was chosen in the nspopup boxes in the otherSourcesTagsViewController *sourcesSearchWindowController holds a window that is used as a sheet from MainWindowController. It is opened when the user uses the search box in the MainWindowController and allows the user to select which entries from core data to use to populate the nspopup boxes in the otherSourcesTagsViewController Ok, at this point I am sure you are well and truly confused, so I figured I would explain the way I envision a standard use would be: *app opens *user opens a movie file with no metadata (yet) *he enters the name of the movie the file is a recording off into the search-box in the toolbar *the sourcesSearchWindowController pops up its modal window, and downloads tagging information from online sources in addition to what is cached in the core data repository and displays that a list of results to the user *the user checks off which results he thinks is relevant, then clicks ok which dismisses the modal window *the user now uses the NSTabView to go to the view controlled by otherSourcesTagsViewController where he is presented with a bunch of NSPopups which have been populated with the information from the chosen search results. He works his way through the popup boxes, selecting the most accurate information (these might be from a variety of sources) *once that is done, he goes back to the nstabView and selects the view controlled by currentTagsViewController. This presents him with a bunch of text fields which are now populated by all the entries he selected from the nspopup menus, and he can make any fine adjustments he wishes *once he is happy with all the metadata, he goes to the save menu and the changes are written to the movie file Ok, so this means that we have three different views/windows (all of which are instantiated by the MainWindow) who all interact with the core data: 1. the search picks out results and narrows down the number of hits (by user selecting the ones he likes) 2. the nspopup bar view picks those narrowed down results apart and pulls out the information for the user to mix and match single entries he likes 3. the textfield view displays the single selected elements from the popups and allows the user to make fine adjustments (will not be saved into core data) At first I figured this was a nice way of designing things. Each separate view element/window has it's own controller, and thereby reducing the amount of different tasks that the MainWindowController needs to deal with. I am now reconsidering, as the amount of communication that will now have to happen between these three views is causing me many headaches, as I am struggling to see how I can get this all tied together. What I am hoping for, is that there is a way that the different views can create subsets of the core data repository (as in the search followed by the user selecting his desired results) which will be held in the managedObjectContext (or similar) and can then later be accessed by the other views. What I mean, is that one operation of narrowing down the set of data will be held so that a the next operation executed is now only executing on that narrowed set. This would mean that each of my views didn't need to
Re: [iPhone] Addressbook group problem
Thank you Roland, and Luke! I got it...thank you for your pointers! ABRecordRef group = CFArrayGetValueAtIndex(grpval, i); NSString *groupName = (NSString *)ABRecordCopyCompositeName(group); This works, finally... Thank you again! James On 2009/7/13, at 下午 3:18, Roland King wrote: Well they aren't strings, they are some kind of opaque type which represents a group. So you can't find it using CFArrayContainsValue with a String. The name is a property of the Group object which is returned. You'll have to iterate the array, get the property for each group which is the name and test it against the name you want to add. This is all documented in the Address Book Programming Guide For iPhone OS whereh it explains what records are and tells you how to get properties out of them. The ABGroup Reference documentation then tells you what the one single property for a group is. (kABGroupNameProperty) Can't say this is the easiest documentation to fully understand on the first reading but bouncing around a bit you should be able to sort out how it works (and if you have documentation improvement suggestions you should hit the link at the bottom and make some, I'm just about to!) James Lin wrote: Thank you Roland. Actually, I tried that function...but there is a problem that I can't figure out. the following is my code segment... ABAddressBookRef addressBook=ABAddressBookCreate(); CFArrayRef grpval= ABAddressBookCopyArrayOfAllGroups(addressBook); CFIndex groupCount = ABAddressBookGetGroupCount(addressBook); CFRange range = CFRangeMake(0, 1); NSArray *convertedArray = (NSArray *)grpval; if (CFArrayContainsValue(grpval, range, @Dangle Three)) { NSLog(@Yes, it contains the group); } NSLog(@tthe group count is %d, groupCount); NSLog(@the group name is %@, (NSString *)CFArrayGetValueAtIndex(grpval, 0)); NSLog(@The converted group is nsarray %@, [convertedArray objectAtIndex:0]); the output i get from the NSLog statements are: *2009-07-13 14:29:08.686 KSOne[7520:20b] tthe group count is 1* *2009-07-13 14:29:08.687 KSOne[7520:20b] the group name is NSCFType: 0x119e1a0* *2009-07-13 14:29:08.688 KSOne[7520:20b] The converted group is nsarray NSCFType: 0x119e1a0* * * *For some reason, the toll-free bridging doesn't work.* *although i can get the count of the group array of 1 correctly, * *the actual group name remains illusive to me :(* * * *any ideas? * *what's NSCFType?* *what am I doing wrong?* * * *Thank you in advance...* * * *James* On 2009/7/13, at 下午 1:15, Roland King wrote: ABAddressBookCopyArrayOfAllGroups()? James Lin wrote: Hi, Sorry I didn't frame my question more clearly... The part I am having trouble with is finding out if a group name already exists in the addressbook, is there a way to do this? the ABGroup documentation has no function that allows this... any suggestions? Thank you in advance... James On 2009/7/11, at 下午 9:36, Luke Hiesterman wrote: The group doesn't have a name when you create it. Try setting the name after creation rather than getting it. Luke Sent from my iPhone. On Jul 11, 2009, at 12:50 AM, James Lin jamesclin...@gmail.com mailto:jamesclin...@gmail.com wrote: Hi all, Anyone familiar with the Addressbook framework? I can't seem to be able to add a group into the addressbook only ONCE. if i use ABRecordRef group = ABGroupCreate(); to get a handle on group, calling NSString *groupName = (NSString *)ABRecordCopyCompositeName(group); returns a NULL. so I can't seem to be able to check if a group name already exists and don't have to re-create the group again. Can you please help me and point me in the right direction? How do I create group only once? Thank you and best regards... James ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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/luketheh%40apple.com This email sent to luket...@apple.com mailto:luket...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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/rols%40rols.org This email sent to r...@rols.org mailto:r...@rols.org ___ 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
Trouble with binary data and byte buffers
Hi, I'm having some confusion here over displaying raw binary data. I have my NSMutableData object that I'm getting the bytes from. As I understand it, there are different ways to get the bytes. The -getBytes:range: method NSRange r = NSMakeRange(x, y); char buf[y]; [data getBytes:buf length:r]; Or the -bytes or -mutableBytes methods char buf = [data bytes]; What is the generally accepted method of doing this? I'm using the first method, as the other one sometimes crashes. Second, I'm testing the data with the following code: for (int i = 0; i aNumber; i ++) { NSLog(@%02X, buf[i]); } This is what's really bothering me because I'll get normal bytes, like 2E 00 AA, but sometimes, seemingly randomly, there are six leading F's. Something like: 0E 00 FF8E AA FF 4E FF0C FF9A 9C C0 Viewing the data in a hex editor reveals that the values on the end of these F's are correct. For some reason, the data is just preceded by extraneous F's... Any help appreciated, thanks! ___ 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: Trouble with binary data and byte buffers
On 13 Jul 2009, at 22:02, Chase Meadors wrote: Hi, I'm having some confusion here over displaying raw binary data. I have my NSMutableData object that I'm getting the bytes from. As I understand it, there are different ways to get the bytes. The -getBytes:range: method NSRange r = NSMakeRange(x, y); char buf[y]; [data getBytes:buf length:r]; getBytes:length: takes a scalar argument for length, not a NSRange object. You're probably thinking of getBytes:range:. However, I'd recommend strongly against using stack allocation (particularly variable-length stack allocation) for a buffer of unknown, potentially large size. Or the -bytes or -mutableBytes methods char buf = [data bytes]; What is the generally accepted method of doing this? I'm using the first method, as the other one sometimes crashes. It won't crash if you assign it to a variable of the proper type: char *buf = [data bytes]; Second, I'm testing the data with the following code: for (int i = 0; i aNumber; i ++) { NSLog(@%02X, buf[i]); } This is what's really bothering me because I'll get normal bytes, like 2E 00 AA, but sometimes, seemingly randomly, there are six leading F's. Hardly random. It's occurring for every value with the high bit set (0x80 - 0xff). Read: http://en.wikipedia.org/wiki/Sign_extension Then switch char to unsigned char and you'll get the results you're expecting. ___ 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: Trouble with binary data and byte buffers
On 14/07/2009, at 3:02 PM, Chase Meadors wrote: for (int i = 0; i aNumber; i ++) { NSLog(@%02X, buf[i]); } This is what's really bothering me because I'll get normal bytes, like 2E 00 AA, but sometimes, seemingly randomly, there are six leading F's. Something like: 0E 00 FF8E %X expects an unsigned number but you are passing it a char, which is signed, so it's sign extending and displaying the result as if the high bit were a sign bit. You'll notice it's not random, it's whenever the high bit is set. Also, your buf should be declared char*, not char, which is why it's crashing. --Graham ___ 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
[Moderator] Re: ★★★★ Cocoa proj ect for sale
This type of announcement is NOT appropriate for this list. moderator On 2009-07-13, at 4:49 PM, Houdah - ML Pierre Bernard wrote: HoudahStudy 2.0 (aka Ebbinghaus). Study card software. Late alpha / early beta. CoreData, CoreAnimation, GC, properties, … Ebbinghaus 1.0 was freeware 2.0 is a complete rewrite. Not yet released. Inquire via email to pierre.bern...@houdah.com Current build available upon request___ 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/scott%40cocoadoc.com This email sent to sc...@cocoadoc.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
[iPhone] Network connection between 2 iPhones-Can GKVoiceChat be my solution?
Hi all... Continuing on with my network between 2 iPhone quest... Thanks to Luke who made me aware of Game Kit and GKVoiceChat. As I am new to network programming, I need you to help me make sense of the documentation. If I am reading the GKVoiceChat documentation correctly...GKVoiceChat works in the following manner: 1. provide each client with an arbitrary participant ID and try to connect through GKVoiceChatService (is it a server/service provided by Apple?), and the service will allow the 2 iPhones to discover each other and make connection? 2. Session can be created over Bonjour service. Can i create a Session object from the participantID that I provide for the two iPhones? 3. There is a method called voiceChatService:sendData:toParticipantID: as part of the protocol. The documentation says: Implement the client’s voiceChatService:sendData:toParticipantID: method. - (void)voiceChatService:(GKVoiceChatService *)voiceChatService sendData:(NSData *)data toParticipantID:(NSString *)participantID { [session sendData: data toPeer:[NSArray arrayWithObject: participantID] withDataMode: GKSendDataReliable error: nil]; } The service calls the client when it needs to send data to other participants in the chat. Most commonly, it does this to establish its own real-time connection with other participants. As both the GKSession and GKVoiceChatService use an NSData object to hold their data, simply pass it on to the session. If the same network is being used to transmit your own information, you may need to add an identifier before the packet to differentiate your data from voice chat data. Does this mean I can also send my own data over the internet through this service once a voicechat connection is made? 4. Anyone know if sample code is available anywhere on the net for GKVoiceChat? 5. In the Game Kit Programming Guide documentation, it mentioned two methods voiceChatService:sendData:toParticipantID: voiceChatService:sendRealTimeData:toParticipantID: However, these two methods are mysteriously missing from the GKVoiceChatService Class documentation. Am I missing something? If I am reading the documentation correctly: does this mean I can use the GKVoiceChatService that discovered each through the service and SEND MY OWN DATA between the two iPhones? If my impressions are correct, this class might be the solution I am looking for... Can you please help me confirm? Thank you in advance... James___ 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