• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with getting access to fields of Core Data model
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with getting access to fields of Core Data model


  • Subject: Problem with getting access to fields of Core Data model
  • From: Ronald Hofmann <email@hidden>
  • Date: Tue, 05 Aug 2014 07:21:41 +0200

See My code below.
This works so far if I only use the field password for output. See line "Here is the problem"

When changing to this instead, which should work in my opinion, I get Errors:
txtGesamt.text = txtGesamt.text + "\(res.username), \(res.password)  \n"

/Users/ronny/Dropbox/CoreDataYouTube/vcMain.swift:73:16: 'AnyObject' does not have a member named 'username'

What I don“t understand. If res.password is correct  res.username should work as well.
What am I doing wrong? Any idea?

Greetings from Switzerland, Ronald Hofmann
---

My code:
func btnLoadWrapper ( myFlag: Bool ) {

	var appDel :AppDelegate	= (UIApplication.sharedApplication().delegate as AppDelegate )
	var context:NSManagedObjectContext = appDel.managedObjectContext

	var request = NSFetchRequest(entityName: "Users")
	request.returnsObjectsAsFaults = false

	txtGesamt.text   = "" 																																																																		 			// clearing UITextView

	request.predicate = NSPredicate (format: "username = %@",txtUsername.text)

	var results:NSArray = context.executeFetchRequest(request, error: nil)

	if(results.count > 0) {

			for res in results { 									//Writing the contents into UITextView txtGesamt
												       		println("\(res)") 			//returns result 1
Here is the problem		txtGesamt.text = txtGesamt.text + "\(res.password)  \n" //see result 2
			}
		}
	}


result 1
<NSManagedObject: 0x7ff5925657d0> (entity: Users; id: 0xd000000000800000 <x-coredata://04772CE3-D027-4770-A536-D8A3B12CBFB6/Users/p32 <x-coredata://04772CE3-D027-4770-A536-D8A3B12CBFB6/Users/p32>> ; data: {
    password = MyPassword;
    reference = Gargantua20;
    username = EuroMillions;

result 2 appear in txtGesamt (these passwords actually change)
MyPassword
MyPassword
.
.
.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Prev by Date: Re: Intercepting *all* keystrokes in NSView?
  • Next by Date: Is substitution of block-function parameters OK when it's an object type?
  • Previous by thread: Re: Intercepting *all* keystrokes in NSView?
  • Next by thread: Is substitution of block-function parameters OK when it's an object type?
  • Index(es):
    • Date
    • Thread