archive-be.com » BE » B » BENNYMICHIELSEN.BE

Total: 348

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • apple – Page 2 – Benny Michielsen
    Previous page Page 1 Page 2 Search Search for Search Follow me Recent Comments Rick on Partitioning and wildcards in an Azure Data Factory pipeline BennyM on WCF HTTPS And Request Entity Too Large Justin on WCF HTTPS And Request Entity Too Large The Morning Brew Chris Alcock The Morning Brew 2052 on Getting up and running with Mono and Raspberry Pi 3 bhldev on Exposing iCal data in WebAPI

    Original URL path: http://blog.bennymichielsen.be/tag/apple/page/2/ (2016-04-29)
    Open archived version from archive


  • Benny Michielsen – Page 11 – .net developer with a touch of Cocoa
    Comments on Cocoa Programming for Mac OS X Ch 13 16 Cocoa Programming for Mac OS X Ch 9 12 Read part one here part two here and get the book here The plot thickens Chapter 9 NSUndoManager For those wondering what that NS is doing everywhere it comes from NeXTSTEP more information about it here This chapter is all about adding undo redo capabilities to your application and maybe it s because the current sample application is well a sample but it s rather easy to add this capabilities to your program Also you get it integrated with the menu bar at no extra cost the window shows that there are changes and the undo and redo buttons come to live The underlying mechanism relies heavy upon Key Value coding which was discussed in chapter 7 again demonstrating it power void insertObject Person p inEmployeesAtIndex int index NSLog adding to p employees NSUndoManager undo self undoManager undo prepareWithInvocationTarget self removeObjectFromEmployeesAtIndex index if undo isUndoing undo setActionName Insert Person self startObservingPerson p employees insertObject p atIndex index Chapter 10 Archiving The sample application now tracks changes and when you try to close an edited window it asks if it should save its changes So the logical next chapter is about adding this capability In this chapter we learn that the notion of an interface in Net actually also exists in Objective C but it s called a protocol and unlike Net and Java you can have optional methods in a protocol so any method marked optional does not need to be implemented Archiving is coupled with the NSCoding protocol and the abstract NSCoder class most of the time you ll be dealing with the abstracted class which hides the underlying mechanism Implementing this can be compared to the implementation in Net Though it requires less code to write since your object graph is stored automatically in a file You can configure the extension and the icon from within XCode it was also nice to see that OS X had automatically associated the extension with my application import Foundation Foundation h interface Person NSObject NSCoding NSString personName float expectedRaise property readwrite copy NSString personName property readwrite float expectedRaise end import Person h implementation Person id init super init expectedRaise 5 0 personName New Person return self void dealloc personName release super dealloc synthesize personName synthesize expectedRaise void setNilValueForKey NSString key if key isEqual expectedRaise self setExpectedRaise 0 0 else super setNilValueForKey key void encodeWithCoder NSCoder coder coder encodeObject personName forKey personName coder encodeFloat expectedRaise forKey expectedRaise id initWithCoder NSCoder coder super init personName coder decodeObjectForKey personName retain expectedRaise coder decodeFloatForKey expectedRaise return self end Chapter 11 Basic Core Data You thought it was good well it just gets better All the code we still had to write to add undo redo change tracking and archiving to our application can be done without writing any line as illustrated with this chapter Again we see the power of Key Value coding Chapter 12 Nib Files and NSWindowController Nib files contain the state of the window designed with interface builder this chapter tells you how you can postpone loading a window panel to save memory and resources It also how you can load classes this includes Windows custom classes etc by their name Much like the Activator in Net IBAction showAboutPanel id sender BOOL successful NSBundle loadNibNamed About owner self if successful NSLog Loaded nib from NSBundle else NSLog Unable to load nib RaiseMan Chapter 9 zip 72 21 kb RaiseMan Chapter 10 zip 74 18 kb CarLot Chapter 11 zip 43 54 kb RaiseMan Chapter 12 zip 85 23 kb Author BennyM Posted on 02 06 2008 Categories Software Development Tags book c cocoa development objective c programming Leave a comment on Cocoa Programming for Mac OS X Ch 9 12 Cocoa Programming for Mac OS X Ch 6 8 View Chapters 1 5 here get the book here The title of chapter 6 Helper Objects did not sound good Whenever I find classes with the words Helper or Util in their name this usually indicates a code smell and most of time the underlying problem is a leaky domain model Turns out something completely different is the subject of this chapter delegates They can be compared with delegates in Net though they are being used in a different way I ll illustrate with a sample The TableView UI component deals with displaying data like a table compare this with the Net grid What it displays however is not part of his responsibility this behaviour can be added though by using delegates The tableView has a delegate member which you can set if that object implements methods which map to delegate methods of the tableView they will be called otherwise they won t This means that you don t need to implement everything just what you need I think in Net this behaviour would be implemented by using interfaces So if you had your own grid component it s datasource could be set to something of type IDatasource which would provide the necessary functionality that would be called by the grid component Overall this is off course a powerful feature though implementing it requires attention misspelling the method name means that your method won t be called and you won t get any errors The author states that the best way is to look at the documentation and copy paste the method signatures in your code Chapter 7 Key Value Coding Key Value Observing A short chapter only 12 pages but it seems to be a core concept If you have an instance variable foo in class Bar you can have other objects be notified of changes to it This can be compared to the Net INotifyPropertyChanged interface and its interweaving with databinding Since the observers call the methods valueForKey and setValue forKey you need to make sure your code follows the strict naming convention to get this functionality If you are changing

    Original URL path: http://blog.bennymichielsen.be/page/11/ (2016-04-29)
    Open archived version from archive

  • Entity Framework 4.1 – One To One Mapping – Benny Michielsen
    CustomerContext DbContext public IDbSet Customer Customers get set protected override void OnModelCreating DbModelBuilder modelBuilder modelBuilder Entity Address HasRequired x x Customer WithRequiredDependent x x Address base OnModelCreating modelBuilder I m saying here that the address entity has a required customer property and that the customer class is actually in charge MSDN reference Resulting database structure Another way to achieve the same result public class CustomerContext DbContext public IDbSet Customer Customers get set protected override void OnModelCreating DbModelBuilder modelBuilder modelBuilder Entity Address HasRequired x x Customer WithRequiredDependent modelBuilder Entity Customer HasRequired x x Address WithRequiredPrincipal base OnModelCreating modelBuilder MSDN link on WithRequiredPrincipal You saw that the WithRequiredPrincipal and Depedant actually have one taking a lambda and one with no arguments This allows you to exclude a navigation property and still get a proper one to one mapping Which brings me back to my starting point public class Customer public Customer Address new Address public Guid Id get set public string Name get set public Address Address get set public class Address public Guid Id get set public string City get set public string Country get set public string Street get set public class CustomerContext DbContext public IDbSet Customer Customers get set protected override void OnModelCreating DbModelBuilder modelBuilder modelBuilder Entity Customer HasRequired x x Address WithRequiredPrincipal base OnModelCreating modelBuilder Author BennyM Posted on 02 06 2011 02 06 2011 Categories Software Development Tags entity framework 18 thoughts on Entity Framework 4 1 One To One Mapping Pingback The Morning Brew Chris Alcock The Morning Brew 865 Sergii Lazurenko says 09 08 2011 at 12 13 Good post Thank you very much Benny Reply yuriylsh says 26 08 2011 at 20 23 Thank you Benny your post helped a lot to resolve one problem I had in my EF code Appreciate it Reply Shimmy says 15 05 2012 at 05 31 Is there a way to use data annotations instead of the fluent API in this scanario 0 1 1 Reply Kevin Bolander says 22 10 2012 at 06 01 thank you nice decription much appreciated tyty Reply User123 says 12 12 2012 at 06 07 How to display on the web i e i mean calling the function in the Controller action explain that also given a Customer Id it should display the both related rows from Customer and Address Reply Pingback Entity Framework Friend or Foe Blue Collar Nerd BillJam says 14 03 2013 at 21 14 That s fine except Address never gets saved to the database since there is no DBSet for it in the Context first of the both ends required scenarios I never tried the other Reply Jake says 02 06 2013 at 08 59 Hi i v used this approeach but when i see in database there is not a column created customer for Address in fact when i want to retrive data it says null reference exception may you help me Reply Loukouzou says 12 07 2013 at 04 39 Clean concise explanations Thanks Reply

    Original URL path: http://blog.bennymichielsen.be/2011/06/02/entity-framework-4-1-one-to-one-mapping/?replytocom=222 (2016-04-29)
    Open archived version from archive

  • Entity Framework 4.1 – One To One Mapping – Benny Michielsen
    CustomerContext DbContext public IDbSet Customer Customers get set protected override void OnModelCreating DbModelBuilder modelBuilder modelBuilder Entity Address HasRequired x x Customer WithRequiredDependent x x Address base OnModelCreating modelBuilder I m saying here that the address entity has a required customer property and that the customer class is actually in charge MSDN reference Resulting database structure Another way to achieve the same result public class CustomerContext DbContext public IDbSet Customer Customers get set protected override void OnModelCreating DbModelBuilder modelBuilder modelBuilder Entity Address HasRequired x x Customer WithRequiredDependent modelBuilder Entity Customer HasRequired x x Address WithRequiredPrincipal base OnModelCreating modelBuilder MSDN link on WithRequiredPrincipal You saw that the WithRequiredPrincipal and Depedant actually have one taking a lambda and one with no arguments This allows you to exclude a navigation property and still get a proper one to one mapping Which brings me back to my starting point public class Customer public Customer Address new Address public Guid Id get set public string Name get set public Address Address get set public class Address public Guid Id get set public string City get set public string Country get set public string Street get set public class CustomerContext DbContext public IDbSet Customer Customers get set protected override void OnModelCreating DbModelBuilder modelBuilder modelBuilder Entity Customer HasRequired x x Address WithRequiredPrincipal base OnModelCreating modelBuilder Author BennyM Posted on 02 06 2011 02 06 2011 Categories Software Development Tags entity framework 18 thoughts on Entity Framework 4 1 One To One Mapping Pingback The Morning Brew Chris Alcock The Morning Brew 865 Sergii Lazurenko says 09 08 2011 at 12 13 Good post Thank you very much Benny Reply yuriylsh says 26 08 2011 at 20 23 Thank you Benny your post helped a lot to resolve one problem I had in my EF code Appreciate it Reply Shimmy says 15 05 2012 at 05 31 Is there a way to use data annotations instead of the fluent API in this scanario 0 1 1 Reply Kevin Bolander says 22 10 2012 at 06 01 thank you nice decription much appreciated tyty Reply User123 says 12 12 2012 at 06 07 How to display on the web i e i mean calling the function in the Controller action explain that also given a Customer Id it should display the both related rows from Customer and Address Reply Pingback Entity Framework Friend or Foe Blue Collar Nerd BillJam says 14 03 2013 at 21 14 That s fine except Address never gets saved to the database since there is no DBSet for it in the Context first of the both ends required scenarios I never tried the other Reply Jake says 02 06 2013 at 08 59 Hi i v used this approeach but when i see in database there is not a column created customer for Address in fact when i want to retrive data it says null reference exception may you help me Reply Loukouzou says 12 07 2013 at 04 39 Clean concise explanations Thanks Reply

    Original URL path: http://blog.bennymichielsen.be/2011/06/02/entity-framework-4-1-one-to-one-mapping/?replytocom=231 (2016-04-29)
    Open archived version from archive