Re: Communication between objects
Thanks all to who replied for taking the time to sort me out. Your replies have and will be helpful to my understanding of what goes on. I'll let it sink into my head a bit more in the morning (It's 3:16am here in Sydney). Kind regards to all, Jason ___ 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: Communication between objects
OK, now I *think* I've got a bit idea. What I've been trying to do is get an ivar from object1 into object2 *directly* without using the controller as a "middleman" Is it true that I have to set up properties (using Objc 2) to get and set the ivars *via* the controller? I just did that and got it to work. Can i only communicate between objects via the controller who (as obviously named) it controls the flow of data? The only reason I ask this is because after reading Object-Oriented Programming with Objective-C - The Object Model - Figure 3-2 "The object network" shows each object sending messages to each other. Is that picture very abstracted? Because if it is, that figure has messed with my brain. On 12/02/2009, at 02:56 , I. Savant wrote: On Wed, Feb 11, 2009 at 10:42 AM, Jason Wiggins wrote: I understand MVC ... Sorry, but I disagree. You've still got some concepts 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: Communication between objects
Hi Clint (and I.S.) Thanks for your replies. I understand MVC and am happy with that now that a few thoughts have been cleared for me (thanks I.S.). OK, I now understand that and object knows nothing about its parent. Cool. I thought that was the case, but I wasn't convinced. Now, I understand I need a pointer to the "other object", but I am failing (in a BIG way) in understanding HOW to get it or create it. myControllerObject has a pointer to it's children because it knows about it because it created it. But if modelObject1 doesn't know modelObject2 even exists, how can I create a pointer to it? Where do I get this reference from? Pseudo code... @interface ModelObject1 *modelObject1; ModelObject2 *modelObject2; @implementation myControllerObject { int one, two; modelObject1 = [[ModelObject1 alloc] init]; // I now have object 1 modelObject2 = [[ModelObject2 alloc] init]; // I now have object 2 one = [modelObject1 doMethod]; // doMethod returns an int two = [modelObject2 doMethod]; // doMethod returns an int } ... // The "code" above I understand and works OK. @interface @implementation modelObjectA { int a; a = [modelObject2 doMethod]; } If I do the above, I get "error:'modelObject2' undeclared (first use in this function)" What do I do in modelObject1's code to make this work? Where do I get a reference for the pointer? Thanks, Regards, Jason On 12/02/2009, at 02:00 , Clint Shryock wrote: in order for modelObject1 to talk to modelObject2, it must have a reference to that object, similar to how myControllerObject has a reference to both modelObject1 and modelObject2 which you use to send messages. +Clint On Wed, Feb 11, 2009 at 8:42 AM, Jason Wiggins > wrote: Hi all, Can someone please help me with this, I'm tearing my hair out! Say I have myControllerObject. I alloc and init modelObject1 and also modelObject2. How do I access the ivars of modelObject1 from modelObject2 and vice versa? modelObject1 and modelObject 2 both exist somewhere in memory, so how do I get a pointer to or make a connection between these two object? Also, how do I access the ivars of myControllerObject from either modelObject1 or modelObject2? Is it possible to find out from myObject1 or myObject2 who init and alloc them? From what I've read to far (Objective C-2.0 Programming Language and Cocoa Fundamentals Guide) I've been unable to find the answer to these questions. I can send messages from myControllerObject to myObject1 or myObject2 and get returned information no worries, that I do get. Thanks, Regards, Jason ___ 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/cts3e1%40gmail.com This email sent to cts...@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
Communication between objects
Hi all, Can someone please help me with this, I'm tearing my hair out! Say I have myControllerObject. I alloc and init modelObject1 and also modelObject2. How do I access the ivars of modelObject1 from modelObject2 and vice versa? modelObject1 and modelObject 2 both exist somewhere in memory, so how do I get a pointer to or make a connection between these two object? Also, how do I access the ivars of myControllerObject from either modelObject1 or modelObject2? Is it possible to find out from myObject1 or myObject2 who init and alloc them? From what I've read to far (Objective C-2.0 Programming Language and Cocoa Fundamentals Guide) I've been unable to find the answer to these questions. I can send messages from myControllerObject to myObject1 or myObject2 and get returned information no worries, that I do get. Thanks, Regards, Jason ___ 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
NSTokenField Represented Objects
Hello all, I'm having a bit of trouble with NSTokenFields and represented objects. What I am trying to achieve is to create a predicate from text entered in a token field. It goes like this: User enters text, gets a completion if necessary, types tokenising character, token created, user presses a start button, the token's represented object returns a uti for inclusion in the predicate. The token field has completions for substring method implemented in its delegate as such: - (NSArray *)tokenField:(NSTokenField *)tokenField completionsForSubstring:(NSString *)substring indexOfToken: (NSInteger)tokenIndex indexOfSelectedItem:(NSInteger *)selectedIndex { ... else if (tokenField == fileTypeTokenField) { NSArray *matchingFileTypes = [[fileTypeArray valueForKey:@"description"] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@", substring]]; return matchingFileTypes; ... fileTypeArray is an array of dictionaries comprising a description key and a UTI key. All is good for the user entering some text in the token field and getting matches for the substring. The user types the tokenising character and the token is created. But now it seems there is no connection to the dictionary object. The class of the represented object is now NSCFString not NSDictionary. I also have this delegate method implemented: - (NSString *)tokenField:(NSTokenField *)tokenField displayStringForRepresentedObject:(id)representedObject { if (tokenField == fileTypeTokenField) { return representedObject; } } Do I have to implement tokenField:representedObjectForEditingString: ? If so how? Any ideas or thoughts would be greatly appreciated. Regards, Jason ___ 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 [EMAIL PROTECTED]
Autocomplete from an array of dictionaries
Hi, I'm working on an autocompletion system such as with mail To: Cc: fields etc. I have an array of dictionaries and I want the autocomplete to match to the key "description" This code below works great for an array of strings: NSArray *matchingNames = [namesArray filteredArrayUsingPredicate: [NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@", substring]]; But how do I get the above code to match to a specific key from a dictionary? Regards, Jason Wiggins ___ 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 [EMAIL PROTECTED]
[SOLVED] Autocomplete from an array of dictionaries
Note to self: RTFM! I was trying: NSArray *matchingNames = [[namesArray objectForKey:@"description"] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@", substring]]; which doesn't work What I wanted was: NSArray *matchingNames = [[namesArray valueForKey:@"description"] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@", substring]]; Jason On 23/10/2008, at 19:06 , Jason Wiggins wrote: Hi, I'm working on an autocompletion system such as with mail To: Cc: fields etc. I have an array of dictionaries and I want the autocomplete to match to the key "description" This code below works great for an array of strings: NSArray *matchingNames = [namesArray filteredArrayUsingPredicate: [NSPredicate predicateWithFormat:@"SELF beginswith[cd] %@", substring]]; But how do I get the above code to match to a specific key from a dictionary? Regards, Jason Wiggins ___ 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 [EMAIL PROTECTED]
Re: NSTableView bindings and current selection
On 09/09/2008, at 06:19 , Corbin Dunn wrote: On Sep 8, 2008, at 3:30 AM, Jason Wiggins wrote: Hello all, I have a tableView (showing query results) that has its values bound to an array controller; that works fine. I also have a NSPathControl showing the path of the selected item; this works fine too. I have implemented a right-click contextual menu to "Show in Finder..." the selected item in the tableView. My question is, how do I get the path of the selected item so my showInFinderMenuAction: method does as it's supposed to do? To be totally honest, even though I have got the menu working (it's a menuForEvent:theEvent method) and I can log the selected row correctly, I'm unsure of what to do next to implement the contextual menu. As the tableView implements bindings, I can't see a way of getting the selected items row/column value, let alone that row's path reference. Any help would be greatly appreciated. In addition to what Ben said, please look at the DragNDropOutlineView demo app, which does this (albeit without bindings). corbin Thanks Ben and Corbin, I'll check this out. Regards, Jason ___ 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 [EMAIL PROTECTED]
NSTableView bindings and current selection
Hello all, I have a tableView (showing query results) that has its values bound to an array controller; that works fine. I also have a NSPathControl showing the path of the selected item; this works fine too. I have implemented a right-click contextual menu to "Show in Finder..." the selected item in the tableView. My question is, how do I get the path of the selected item so my showInFinderMenuAction: method does as it's supposed to do? To be totally honest, even though I have got the menu working (it's a menuForEvent:theEvent method) and I can log the selected row correctly, I'm unsure of what to do next to implement the contextual menu. As the tableView implements bindings, I can't see a way of getting the selected items row/column value, let alone that row's path reference. Any help would be greatly appreciated. Regards, Jason ___ 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 [EMAIL PROTECTED]
Object networks
Hi everyone, I've been reading Object-Oriented Programming with Objective-C, Cocoa Fundamentals Guide and The Objective-C 2.0 Programming Language guide and I still have an unanswered question regarding object networks. Say I have my controller object "Controller", a model class "Model" and a custom class "textParser". Controller creates an instance of both Model and textParser. As such, Controller can communicate with both the instantiated classes as it has a direct reference to them. But how can I communicate between Model and textParser? How do they know about each other? I have an #import statement in the respective class in both cases but I don't understand where any connection lies beyond that. Sure they know about each others class, but not the instances of that class. More abstractly, how do I get one arbitrary object to communicate with another? What reference do I use? file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_3.html states: "An application typically sets outlet connections between its custom controller objects and objects on the user interface, but they can be made between any objects that can be represented as instances in Interface Builder, even between two custom objects. As with any instance variable, you should be able to justify its inclusion in a class; the more instance variables an object has, the more memory it takes up. If there are other ways to obtain a reference to an object, such as finding it through its index position in a matrix, or through its inclusion as a function parameter, or through use of a tag (an assigned numeric identifier), you should do that instead." Okay, if there are other ways of referencing an object, how? I haven't found any clear examples of function parameters or tags. file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/OOP_ObjC/Articles/chapter_5_section_1.html talks about an object network, yet doesn't say how to create it. (ref Figure 3-2 Object Network) Any pointers to any docs on how this works would be greatly appreciated. Regards, Jason ___ 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 [EMAIL PROTECTED]
Re: Table column header not highlighted at first
On 16/08/2008, at 11:26 PM, Graham Cox wrote: OK, very simple: it was set in the nib. I didn't realise that presetting this in the nib was possible, so I must have set it up that way more or less by accident. OK, my understanding has improved... (Thanks!) Hi, I have been following this thread and was wondering how you actually set the sort descriptor in the nib. I've looked at the bindings tab and tried different things but haven't yet got it to work. Regards, Jason ___ 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 [EMAIL PROTECTED]
Re: Drawing issues in custom view
Not to worry, just realised what is happening. drawRect: gets called for ALL drawing operations in the view, not just background as I expected. Carry on... Regards, Jason On 11/07/2008, at 1:38 AM, Jason Wiggins wrote: Hi everyone, I have a Custom View in IB with an rounded NSTokenField (Focus ring set to none) and a rounded rect NSButton embedded in it. In XCode I have the Custom View class set to my subclass of NSView, with the following code: - (void)drawRect:(NSRect)rect { NSGradient *gradient = nil; NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect]; [[NSColor blackColor] setFill]; [path fill]; // Create gloss gradient gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] endingColor:[NSColorcolorWithCalibratedWhite:1.0alpha: 0.2]]; // Make a half-height rectangle rect = NSMakeRect(rect.origin.x, (rect.origin.y + (rect.size.height)/2), rect.size.width, (rect.size.height)/2); path = [NSBezierPath bezierPathWithRect:rect]; [gradient drawInBezierPath:path angle:-90]; // Create upper highlight path = [NSBezierPath bezierPath]; [path moveToPoint:NSMakePoint(rect.origin.x, (rect.origin.y + rect.size.height))]; [path lineToPoint:NSMakePoint(rect.size.width, (rect.origin.y + rect.size.height))]; [path closePath]; [path setLineWidth:2]; [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] setStroke]; [path stroke]; } The gradient draws as expected. The upper highlight also draws as expected in the view, but also on the NSTokenView and NSButton, which is unexpected and I don't know why this is so. Can anyone offer any info as to why this is the case? Regards, JJ ___ 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/jwiggins%40optusnet.com.au This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Drawing issues in custom view
Hi everyone, I have a Custom View in IB with an rounded NSTokenField (Focus ring set to none) and a rounded rect NSButton embedded in it. In XCode I have the Custom View class set to my subclass of NSView, with the following code: - (void)drawRect:(NSRect)rect { NSGradient *gradient = nil; NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect]; [[NSColor blackColor] setFill]; [path fill]; // Create gloss gradient gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] endingColor:[NSColorcolorWithCalibratedWhite:1.0alpha: 0.2]]; // Make a half-height rectangle rect = NSMakeRect(rect.origin.x, (rect.origin.y + (rect.size.height)/ 2), rect.size.width, (rect.size.height)/2); path = [NSBezierPath bezierPathWithRect:rect]; [gradient drawInBezierPath:path angle:-90]; // Create upper highlight path = [NSBezierPath bezierPath]; [path moveToPoint:NSMakePoint(rect.origin.x, (rect.origin.y + rect.size.height))]; [path lineToPoint:NSMakePoint(rect.size.width, (rect.origin.y + rect.size.height))]; [path closePath]; [path setLineWidth:2]; [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] setStroke]; [path stroke]; } The gradient draws as expected. The upper highlight also draws as expected in the view, but also on the NSTokenView and NSButton, which is unexpected and I don't know why this is so. Can anyone offer any info as to why this is the case? Regards, JJ ___ 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 [EMAIL PROTECTED]
Re: NSDateComponents question
For the sake of completeness, the second line was incorrect (bracket preceding NSCalendar). It has been corrected in the following snippet: On 02/07/2008, at 10:41 AM, mmalc crawford wrote: NSDate *today = [NSDate date]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; // Get the weekday component of the current date NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:today]; /* Create a date components to represent the number of days to subtract from the current date. The weekday value for Sunday in the Gregorian calendar is 1, so subtract 1 from the number of days to subtract from the date in question. (If today's Sunday, subtract 0 days.) */ NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init]; [componentsToSubtract setDay: - ([weekdayComponents weekday] - 1)]; NSDate *beginningOfWeek = [gregorian dateByAddingComponents:componentsToSubtract toDate:today options:0]; /* Optional step: beginningOfWeek now has the same hour, minute, and second as the original date (today). To normalize to midnight, extract the year, month, and day components and create a new date from those components. */ NSDateComponents *components = [gregorian components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: beginningOfWeek]; beginningOfWeek = [gregorian dateFromComponents: components]; JJ ___ 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 [EMAIL PROTECTED]
Re: NSDateComponents question
Thanks mmalc and Chris. Your help and wisdom is much appreciated. JJ On 02/07/2008, at 10:41 AM, mmalc crawford wrote: On Jul 1, 2008, at 5:20 PM, Jason Wiggins wrote: It look like what I thought was going to be something simple, has turned out to be less so and fraught with danger programatically. I was just thinking though, would it be easier just to covert the weekday value into seconds (weekday * 60 * 60 * 24) and subtract that from the current date? This would save you from the issue of year and month boundaries. Following code is untested (written in Mail): I'm sorry if I've obfuscated Chris's reply. I'd thought it would be possible to save a few steps by reusing the date components object you get from decomposing the start date, but Chris indicates that the short-cut is not guaranteed to work in all situations. His robust solution is to do the following: NSDate *today = [NSDate date]; [NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; // Get the weekday component of the current date NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:today]; /* Create a date components to represent the number of days to subtract from the current date. The weekday value for Sunday in the Gregorian calendar is 1, so subtract 1 from the number of days to subtract from the date in question. (If today's Sunday, subtract 0 days.) */ NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init]; [componentsToSubtract setDay: - ([weekdayComponents weekday] - 1)]; NSDate *beginningOfWeek = [gregorian dateByAddingComponents:componentsToSubtract toDate:today options:0]; /* Optional step: beginningOfWeek now has the same hour, minute, and second as the original date (today). To normalize to midnight, extract the year, month, and day components and create a new date from those components. */ NSDateComponents *components = [gregorian components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate: beginningOfWeek]; beginningOfWeek = [gregorian dateFromComponents: components]; mmalc ___ 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 [EMAIL PROTECTED]
Re: NSDateComponents question
It look like what I thought was going to be something simple, has turned out to be less so and fraught with danger programatically. I was just thinking though, would it be easier just to covert the weekday value into seconds (weekday * 60 * 60 * 24) and subtract that from the current date? This would save you from the issue of year and month boundaries. Following code is untested (written in Mail): NSDateComponents *components = [[NSDateComponents alloc] init]; NSDate *startOfTheWeek; NSDate *now = [NSDate date]; components = [calendar components:NSWeekdayCalendarUnit fromDate:now]; startOfTheWeek = [now addTimeInterval:-([components weekday] * 60 * 60 * 24)]; NSLog(@"The start of the week is %@", startOfTheWeek); JJ On 02/07/2008, at 4:37 AM, mmalc crawford wrote: On Jul 1, 2008, at 10:44 AM, Chris Kane wrote: My apologies; I did do some testing and found that the resultant date was always correct. Could you elaborate on what circumstances this might not be correct? Did you try starting with a starting date of Jan 1, 2009? The Weekday would be 5, the Day 1. Rats, no; I tried the dates at the beginning of 2008, 2003, and 1999... The previous Sunday is December 28, 2008. ... although, hmm, yes, that's the result I get(*). Nevertheless... Passing a Year, Month, Day of (2009, 1, -3) (-3 == 1 - (5 - 1) in your original computation) is passing an out-of-bounds value with dateWithComponents:, with who-knows-what effect. It might be well- defined, it might not be. The result might change between OS releases. In other words, it seems a bit ambiguous, so best to just avoid it. ... point taken. I'll update the documentation accordingly. mmalc (*) NSDateComponents *components = [[NSDateComponents alloc] init]; [components setYear:2009]; [components setMonth:1]; [components setDay:1]; NSDate *testDate = [gregorian dateFromComponents:comps]; [components release]; NSDateComponents *components = [gregorian components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:testDate]; NSLog(@"day: %d, weekDay: %d, delta: %d", [components day], [components weekday], [components day] - [components weekday]); // day: 1, weekDay: 5, delta: -4 [components setDay:([components day] - ([components weekday] - 1))]; [components setWeekday:NSUndefinedDateComponent]; NSDate *beginningOfWeek = [gregorian dateFromComponents:components]; NSLog(@"beginningOfWeek: %@", beginningOfWeek); // beginningOfWeek: 2008-12-28 00:00:00 -0800 ___ 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/jwiggins%40optusnet.com.au This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: NSDateComponents question
Thanks mmalc, much appreciated. I'll give it a go when I get time to code. Regards, JJ On 01/07/2008, at 6:08 PM, mmalc crawford wrote: On Jun 30, 2008, at 10:27 AM, Jason Wiggins wrote: Thanks mmalc for your reply. What you say makes sense. So comps is the whole date (now) minus 3 days. I wasn't expecting that. I should've made it clear what I was trying to achieve. I want to set the start date to the start of the week, hence line 11. 3 was just an arbitrary figure that happens to be today (localised in Sydney at 3:20am) I want to get the weekday and subtract *that* from the current date. I can't get a weekday figure without line 7. Any suggestions? Assuming you want just the actual day of the beginning of the week, rather than a specific time on the day (and assuming a Gregorian calendar and that you want the week to start on a Sunday): NSDate *currentDate = [NSDate date]; /* Get the components required to: (a) determine the current day of the week, and (b) create the day of the beginning of the week. */ NSDateComponents *components = [gregorian components:NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:currentDate]; /* Update the components to represent the beginning of the week by subtracting the weekday number from the current day. Weekday for Sunday in the Gregorian calendar is 1, so subtract 1 from the number of days you want to subtract from the date in question. (If today's Sunday, subtract 0 days.) */ [components setDay:([components day] - ([components weekday] - 1))]; // Create the day for the beginning of the week from the updated components. NSDate *beginningOfWeek = [gregorian dateFromComponents:components]; mmalc ___ 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 [EMAIL PROTECTED]
Re: NSDateComponents question
Thanks mmalc for your reply. What you say makes sense. So comps is the whole date (now) minus 3 days. I wasn't expecting that. I should've made it clear what I was trying to achieve. I want to set the start date to the start of the week, hence line 11. 3 was just an arbitrary figure that happens to be today (localised in Sydney at 3:20am) I want to get the weekday and subtract *that* from the current date. I can't get a weekday figure without line 7. Any suggestions? JJ On 01/07/2008, at 3:02 AM, mmalc crawford wrote: On Jun 30, 2008, at 9:45 AM, Jason Wiggins wrote: 5 NSDateComponents *comps = [[NSDateComponents alloc] init]; 6 NSDateComponents *components = [[NSDateComponents alloc] init]; Why are you creating these objects -- you're just leaking them? 7 unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit; 8 int x = 0; 9 now = [NSDate date]; 10 comps = [calendar components:unitFlags fromDate:now]; 11 x = [comps weekday]; 12 NSLog(@"Weekday is: %i", x); // prints "Weekday is: 3" to the console 13 [comps setDay:-x]; 14 startDate = [calendar dateByAddingComponents:comps toDate:now options:0]; What do you get if you print the other components of comps to the console? Since you initialised 'comps' from 'now', the year component will be 2008. So add another 2008 years to 2008 and you'll get 4016 -- add another six months doubled and you'll get 4017... If you simply want to subtract 3 days from the current date, create a new date components with a day component of -3. NSDate *currentDate = [NSDate date]; NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setDay:-3]; NSDate *date = [gregorian dateByAddingComponents:comps toDate:currentDate options:0]; [comps release]; mmalc ___ 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 [EMAIL PROTECTED]
NSDateComponents question
Hi everyone, Since NSCalendarDate is going to be deprecated in the future, I've started playing with NSDateComponents. I have a question regarding a problem I'm having. I'm getting a wacky date returned at line 15. I'm expecting it to add -3 to the current date, but I get something *way* in the future. I'm not trying to invent a time machine. Here is the code I have: 1 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 2 NSDate *now; 3 NSDate *startDate; 4 NSDate *endDate; 5 NSDateComponents *comps = [[NSDateComponents alloc] init]; 6 NSDateComponents *components = [[NSDateComponents alloc] init]; 7 unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit; 8 int x = 0; 9 now = [NSDate date]; 10 comps = [calendar components:unitFlags fromDate:now]; 11 x = [comps weekday]; 12 NSLog(@"Weekday is: %i", x); // prints "Weekday is: 3" to the console 13 [comps setDay:-x]; 14 startDate = [calendar dateByAddingComponents:comps toDate:now options:0]; 15 NSLog(@"startDate is: %@", startDate); // prints "startDate is: 4017-02-01 02:32:04 +1100" to the console If I change it to the following code, it works as expected: 1 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 2 NSDate *now; 3 NSDate *startDate; 4 NSDate *endDate; 5 NSDateComponents *comps = [[NSDateComponents alloc] init]; 6 NSDateComponents *components = [[NSDateComponents alloc] init]; 7 unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit; 8 int x = 0; 9 now = [NSDate date]; 10 components = [calendar components:unitFlags fromDate:now]; 11 x = [components weekday]; 12 NSLog(@"Weekday is: %i", x); // prints "Weekday is: 3" to the console 13 [comps setDay:-x]; 14 startDate = [calendar dateByAddingComponents:comps toDate:now options:0]; 15 NSLog(@"startDate is: %@", startDate); // prints "startDate is: 2008-06-28 02:36:48 +1000" to the console What I don't understand is why just trying to add -3 in the first lot of code gives me a strange date. Why do I need to get two different NSDateComponents to do what I want to do, or am I missing something? I've read the docs: file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtCalendars.html but haven't found an answer. Thanks, JJ ___ 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 [EMAIL PROTECTED]
Re: Alternative to NSDate's dateWithNaturalLanguageString: ?
Funnily enough, I've just found and been playing with NSCalendarDate and was unaware of the discouragement of using this class until now, thanks Jens. But it's not deprecated *yet* From the docs: Important: Use of NSCalendarDate strongly discouraged. It is not deprecated yet, however it may be in the next major OS release after Mac OS X v10.5. For calendrical calculations, you should use suitable combinations of NSCalendar, NSDate, and NSDateComponents, as described in Calendars in Dates and Times Programming Topics for Cocoa. JJ On 01/07/2008, at 1:14 AM, Jens Alfke wrote: On 30 Jun '08, at 12:29 AM, David Arve wrote: sqlite3_bind_int(sql_statement, 1, one_week); Shouldn't that be sqlite3_bind_double? The variable one_week is declared as double, and I'm pretty sure that seconds-since-1970 intervals are soon going to overflow a (signed) 32-bit int, if they haven't already. Is there a better way for me to get e.g. the dates from my database from this week, this month etc.? Look at "Calendars" in the "Date & Time Programming Guide For Cocoa", which describes how to do manipulations with calendar dates. In a nutshell, you can find the beginning of the week by getting the current date/time, then breaking it into components and setting the day-of-week plus hour/minute/second to zero, then converting back to NSDate. Then you can call -timeIntervalSince1970. (I'd give you an example, but my own code that does this uses the deprecated NSCalendarDate class. I haven't used NSCalendar myself, yet.) —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/jwiggins%40optusnet.com.au This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
Hi Nathan, 1. Noted with thanks. 2. I have realised that as it's not actually connected to anything in the NIB. The only objects that need to instantiated in the NIB are classes that require hooking up in IB? 3. This was a quick and dirty app to understand the popup button thing and I knowingly disregarded memory management, but thanks for the pointers nonetheless. 4. I will have a think and give these a go. Regards, Jason. On 21/06/2008, at 6:43 PM, Nathan Kinsinger wrote: On Jun 20, 2008, at 6:48 AM, Jason Wiggins wrote: Hi everyone, Any help would be greatly appreciated. Jason Some pointers, 1) As has been stated already you don't need the View object at all. In this case the Window holds your view (if you look at the Nib in outline mode and open the content triangle for the Window object you will see that it has a Content View which holds your NSButton and NSPopUpButton). 2) You don't need the Model object in the NIB. The Controller object creates a model instance in it's -awakeFromNib method. The objects you add to the Nib are instantiated when the Nib is loaded so there ends up being two Model objects and the one in the Nib is just wasting memory since nothing else refers to it. With the exception of the first three items (File's Owner, First Responder and Application) the objects in the Nib are objects that will be created when it loads. In your example the MainMenu, Window, Font Manager and your Controller are all objects that are instantiated when the app runs. You don't need to add objects/ classes to the Nib just because they are in your app, only if you need/want to have them created for you. The Controller should be in the Nib in this case, you need it to be created in order to create the Model object and to interact with the view objects already in the Nib. 3) You should add a dealloc method to your Model object, it should release the dataString ivar. Read up on memory managment: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/ObjectOwnership.html#/ /apple_ref/doc/uid/2043 In other memory management issues, the setDataString: method of Model needs to properly release the old string object before overwriting with the new string, otherwise you are leaking memory by not releasing the old string (you should check that the new string is not the same string object as the old one first). Read up on accessor methods: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAccessorMethods.html#/ /apple_ref/doc/uid/TP40003539 4) Just some things to think about/try. You don't need the button to read the popup's value, you can set an action to the NSPopUpButton in the same way that you did for the NSButton, then when the user selects an item the method is called right then. Try creating a new IBAction method for the popup and in it set a different value to the dataString of modelInstance for each menu item in the popup. This more directly models the behavior of a controller, that is it changes the model based on user input. Maybe add an NSTextField to the window and when the Model changes it's dataString it tells the Controller which then updates the text field. Now you have a controller changing the view based on changes in the model. Good luck and have fun :) --Nathan ___ 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 [EMAIL PROTECTED]
Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
The program *does* actually work (ref. the console output shown before. The line with "View..." is the output from the View Class instance method and the line with "Controller..." is the output from the Controller Class instance method). The popup button is connected to both Controller and View Classes. I've read what you've said Graham and I understand what you're saying and where my thinking has been incorrect. But in saying that, I still don't understand why I can't instantiate another class connected to a popup button from my controller and then use a method such as [[viewClassInstance popUpButton] indexOfSelectedItem]; ? Why do I always get 0 logged from and returned from the View class? The only way it seems to work is if I connect all my widgets to the Controller Class. Is there no way of getting another class to do the "dirty work" and return the expected values? In my test case, both Controller and View are connected to the same popup button, but I get different results from the two classes. Regards, Jason On 21/06/2008, at 3:19 PM, Graham Cox wrote: You observation is helpful. I thought that I needed to create a view class. I also thought that with this view class it would have an IBAction (the popup button connected to this) with a switch function, with each case setting an ivar which would be returned to the controller class through getter in the controller when the button was pressed. I you get what I mean. Am I going the "long way round" by doing this? So have I gone too far with the idea of abstraction? By your observation, I should lose the view class I created and connect an IBAction in the controller to the popup button? Looking at your nib file (which at least I can open), the pop-up button is not connected to anything at all, which is probably why it's not doing anything. Also, you have a generic custom object set to "View". That's incorrect - Views are any specific widget or control (in fact any NSView subclass) that you use in IB, so your Button and the Pop-up are already views. You don't need to instantiate one as a standalone custom object - remove it. Your pop-up button should send its action to the controller. That's where the "popUpChoice:" method (or whatever) would go. You don't need a View object as you have created it. The controller in turn will invoke methods on the model to set its state. Generally controllers contain lots of "glue code" which interprets stuff coming from the views (controls) and translate that to state changes in the data model, and vice versa. Custom views are often created, but not in the way you've done it. Instead you drag a "custom view" to a window (typically) and set its class. However at this stage I don't think you need to know about this. Graham On 21 Jun 2008, at 2:56 pm, Jason Wiggins wrote: Thanks Henry for your response. I'll have to read that a couple times to let it sink into my thick skull. Not sure why the DL link is zero length. Here is a better link: http://members.optusnet.com.au/jwiggins/xcode/TestCase.zip The reason I connected things in the way I did was to understand what was and wasn't happening. But then again, as stated, I'm doing something fundamentally 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 [EMAIL PROTECTED]
Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
Apologies, I was using the defaults when I started Xcode. I have re- uploaded with the setting changed as required. Jason On 21/06/2008, at 3:08 PM, Graham Cox wrote: On 21 Jun 2008, at 2:56 pm, Jason Wiggins wrote: http://members.optusnet.com.au/jwiggins/xcode/TestCase.zip OK, it's downloading now. However, it's an Xcode 3.1 project which isn't compatible with Xcode 3. If you want help, you need to help *us* to help you. Set the project to be Xcode 2.4 compatible. 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 [EMAIL PROTECTED]
Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
Graham, You observation is helpful. I thought that I needed to create a view class. I also thought that with this view class it would have an IBAction (the popup button connected to this) with a switch function, with each case setting an ivar which would be returned to the controller class through getter in the controller when the button was pressed. I you get what I mean. Am I going the "long way round" by doing this? So have I gone too far with the idea of abstraction? By your observation, I should lose the view class I created and connect an IBAction in the controller to the popup button? Regards, Jason On 21/06/2008, at 2:05 PM, Graham Cox wrote: Downloading your file produces an empty (zero bytes) file at least when clicking your link and using Finder. But one observation, in an MVC model with a pop-up button, the pop- up button *is* the view, so I'm not sure in what way you have connected this additional view - that sounds wrong. Graham On 20 Jun 2008, at 10:48 pm, Jason Wiggins wrote: Both the Controller and View Classes are connected to the popup button in IB. ___ 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 [EMAIL PROTECTED]
Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
Thanks Henry for your response. I'll have to read that a couple times to let it sink into my thick skull. Not sure why the DL link is zero length. Here is a better link: http://members.optusnet.com.au/jwiggins/xcode/TestCase.zip The reason I connected things in the way I did was to understand what was and wasn't happening. But then again, as stated, I'm doing something fundamentally wrong. Regards, Jason On 21/06/2008, at 2:35 PM, Henry McGilton (Starbase) wrote: On Jun 20, 2008, at 5:48 AM, Jason Wiggins wrote: Hi everyone, If possible, could someone please educate me on the fundamental mistake in my understanding of use of classes/instances/ encapsulation/messaging. I have reread the Object-Oriented Programming with Objective-C but didn't find my answer. I have written a test program with three classes- Model, View and Controller and a Window with a button and a popup button. There are setters and getters to test getting data in/out of the Model Class, which works as expected. Okay, so you have a model, and you have a Controller, and you have a View. Where is this View ?Is it a sub-view of the window's content view ? Both the Controller and View Classes are connected to the popup button in IB. Connected in what way ?Do you have a connection *from* the Controller and *from* the View to the popup button ?If so, why ?What do you expect to happen ?And what is the other button expected to do ? Sounds like the connections are going in the wrong direction. Let's ask the fundamental question: when the popup button changes state, what do you want to happen inside the program ? If I were doing something like this, I would expect that the popup button changing state would send an action message to the controller to tell the controller there's been a change. The controller would then tell the model to update its state, and finally, the controller would send the new state to the view and possibly tell the view to re-display itself. What I want to do is have the View Class to return the value of the selected index of the popup button, but all I ever get is 0. I get the value OK from the Controller Class though. I am obviously doing something fundamentally wrong or misunderstanding "something". Here is the program: ftp://[EMAIL PROTECTED]:21/xcode/TestCase.zip That .zip file is a zero-length file . . . ___ 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 [EMAIL PROTECTED]
Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
Hi everyone, If possible, could someone please educate me on the fundamental mistake in my understanding of use of classes/instances/encapsulation/ messaging. I have reread the Object-Oriented Programming with Objective-C but didn't find my answer. I have written a test program with three classes- Model, View and Controller and a Window with a button and a popup button. There are setters and getters to test getting data in/out of the Model Class, which works as expected. Both the Controller and View Classes are connected to the popup button in IB. What I want to do is have the View Class to return the value of the selected index of the popup button, but all I ever get is 0. I get the value OK from the Controller Class though. I am obviously doing something fundamentally wrong or misunderstanding "something". Here is the program: ftp://[EMAIL PROTECTED]:21/xcode/TestCase.zip The console output I get is as such: [Session started at 2008-06-20 22:39:25 +1000.] 2008-06-20 22:39:25.780 TestCase[1439:10b] AwakeFromNib called 2008-06-20 22:39:25.784 TestCase[1439:10b] AwakeFromNib called 2008-06-20 22:39:25.784 TestCase[1439:10b] AwakeFromNib dataString is: Initial Value // Select the second item from the popup button and press the button 2008-06-20 22:40:12.004 TestCase[1439:10b] dataString is: Initial Value 2008-06-20 22:40:12.005 TestCase[1439:10b] dataString is: 2008-06-20 22:40:12.006 TestCase[1439:10b] dataString is: TESTING... 2008-06-20 22:40:12.007 TestCase[1439:10b] popUpButtonSelectedIndex called and index of selected item is 0 2008-06-20 22:40:12.007 TestCase[1439:10b] View selected index is: 0 2008-06-20 22:40:12.008 TestCase[1439:10b] Controller selected index is: 1 Any help would be greatly appreciated. Jason ___ 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 [EMAIL PROTECTED]
Re: NSPredicate: To be, or not to be
Not to be... I asked this very question of Dominic Giampaolo at last years WWDC as I was running into the same issues with exact phrase searches. I asked if this was now possible in Leopard since I was getting results that contained all the requested words, but not necessarily in their correct order. He stated that in Leopard that it is possible to do exact phrase searches as the Text Contents database had been changed and now this was possible. Unfortunately this is not possible under Tiger as I was told during the same question. JJ On 03/06/2008, at 7:23 PM, Gerriet M. Denkmann wrote: On 3 Jun 2008, at 15:33, Hamish Allan wrote: On Tue, Jun 3, 2008 at 1:37 AM, Gerriet M. Denkmann <[EMAIL PROTECTED]> wrote: This one also works for me. Only it kind of works too well, finding thousands of files. Another example: finds ".../Test.txt" which only contains the line: "Briggel and Braggel" . But I really want only files which contain "Briggel Braggel" or "the Briggel Braggel of today". Are you using Tiger? Yes, I am. Spotlight indexes on words in Tiger; phrase indexing began in Leopard -- the phrase must be enclosed within quotation marks, IIRC (i.e. @"%K LIKE \"[EMAIL PROTECTED]"") string = (without the "<>") predicateFormatContent = @"kMDItemTextContent like %@"; predicate = finds "Briggel and Braggel". Bad string = <"Briggel Braggel"> (Note: " part of string) predicateFormatContent = @"kMDItemTextContent like %@"; predicate = also finds "Briggel and Braggel". Bad string = anything predicateFormatContent = @"kMDItemTextContent like \"[EMAIL PROTECTED]""; or: predicateFormatContent = @"kMDItemTextContent like \'[EMAIL PROTECTED]'"; or: predicateFormatContent = @"kMDItemTextContent like '%@'"; predicate = finds nothing. Also not good. (There are lots of files containing %@ though). string = <'Briggel Braggel'> (Note: ' part of string) predicateFormatContent = @"kMDItemTextContent like %@"; predicate = finds nothing. Still bad. Now I do not have any more ideas. Anyone else? Finding a string containing blanks on Tiger? Kind regards, Gerriet. ___ 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/jwiggins%40optusnet.com.au This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Problem with CIFilters
Hi Julius, Not sure how much help I'll be, but I looked at the screencast and going through it frame by frame, it looks as though the "weird lines" are shadows (inner shadow, not a drop shadow) from the bounding rectangle of the icons. You see the same effect from the bounding area of the "Öffnen" text. (See halfway through the screencast) I can't explain why they only appear sometimes either. Jason On 11/05/2008, at 10:03 PM, Julius Eckert wrote: Hi, I am implementing something like a coverflow. So I have many visual elements in the background and one which is closer to the user and in focus. I put a transparent layer on top of the background elements, which makes them darker. This is very good to make the user focus more on the element in the foreground. I had applied additionally an backgroundFilter to this transparent layer (CIGaussianBlur. CIBoxBlur ... tried both). This effect is so great I really want it in my product. The problem is that some weird lines appear when other layers are drawn in my scene. Did a short screencast to make this more clear: http://www.mygnu.com/julius/temp/SFBug.mov Has anyone an idea , why this is happening and how I can fix it? BTW: its a quicksilver interface called "silverflow", already available as beta on my website www.jeckert.net.tc , freeware Thanks in advance, Julius ___ 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/jwiggins%40optusnet.com.au This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: NSScanner question
Thanks Michael for your reply. I guess I should be doing more validity checks. I'll play some more. Thanks for the suggestion. Regards, Jason On 23/04/2008, at 7:57 PM, Michael Vannorsdel wrote: At first glance I'd say it's crashing because you're not checking if scanUpToCharactersFromSet:intoString: was successful and trying to add what may be an invalid object (foundStrings) to an array. On Apr 23, 2008, at 3:46 AM, Jason Wiggins wrote: I've been playing with NSScanner to cut a string eg: this is a test " So is this"test from a search field into its components. ie. extract the quoted text to be placed into an array as well as the other components, pre and post quoted text. The other components will eventually be split with componentsSeparatedByString. My issue is that if I paste the above text into the search field, all is OK. But if I type in- "test as a test case, it locks up and fails with The Debugger has exited due to signal 11 (SIGSEGV).The Debugger has exited due to signal 11 (SIGSEGV). ___ 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/jwiggins%40optusnet.com.au This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
NSScanner question
Hi, I've been playing with NSScanner to cut a string eg: this is a test " So is this"test from a search field into its components. ie. extract the quoted text to be placed into an array as well as the other components, pre and post quoted text. The other components will eventually be split with componentsSeparatedByString. My issue is that if I paste the above text into the search field, all is OK. But if I type in- "test as a test case, it locks up and fails with The Debugger has exited due to signal 11 (SIGSEGV).The Debugger has exited due to signal 11 (SIGSEGV). The code I am using is as follows: ... NSCharacterSet *quoteCharSet = [NSCharacterSet characterSetWithCharactersInString:@"\""]; NSMutableCharacterSet *alphaNumericAndAsteriskSet = [NSMutableCharacterSet alphanumericCharacterSet]; [alphaNumericAndAsteriskSet addCharactersInString:@"*"]; ... searchWords = [searchWords stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; //discard extraneous characters from nssearchfield searchTermsScanner = [[NSScanner alloc] initWithString:searchWords]; // init the scanner with the search words while ( ! [searchTermsScanner isAtEnd]) { [searchTermsScanner scanUpToCharactersFromSet:quoteCharSet intoString:&foundStrings]; // scan up to a quote [firstScanArray addObject:foundStrings]; //add the quote charcter to the array if ( ! [searchTermsScanner isAtEnd]) { [searchTermsScanner scanUpToCharactersFromSet:alphaNumericAndAsteriskSet intoString:&foundStrings]; [firstScanArray addObject:foundStrings]; } } NSLog(@"%@", [firstScanArray description]); ... [searchTermsScanner release]; [pool release]; return 0; } Can anyone suggest where I am going wrong? Thanks in advance, Jason Wiggins ___ 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 [EMAIL PROTECTED]