BirdWatching app 'incompatible pointer types initializing' - initialization

I just started coding and as I followed Apple's article 'Your Second iOS App:Storyboard', I had a warning that says 'incompatible pointer types initializing Birdsighting *__strong with an expression of type NSString *' from the following code:
detailViewController.sighting = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];

well you are trying to say (IT SEEMS):
NSString *stringInCurrentTableViewRow = [self.dataController objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
BirdSighting *yourObject = stringInCurrentTableViewRow;
you are sure the dataController doesnt contain Strings ;)

Related

What type is a points vector in objective C

I have the following declaration for a function and I don't know what I am doing wrong with regards to the type declaration:
//function is defined in the OpenCVWrapper.mm file .....no errors
+ (NSArray *)analysePoints:(std::vector<cv::Point> )pointsVector{
.......
}
//error is in the OpenCVWrapper.h file
#interface OpenCVWrapper : NSObject
+ (NSArray *)analysePoints:(NSMutableArray *)mutableArray:(std::vector<cv::Point>)pointsArray;
//red marker under the std
#end
I am getting the error "expecting type" for the vector. What am I doing wrong here?
Actually, I found the solution through user11118321 input to look at the bigger picture. I am using this set up in a swift app that uses openCV through a bridging header. It is actually not possible to import or use a vector in swift.

Type Provider not seen by reflection

I'm trying to write my first type provider and am wondering if someone could point where I am going wrong.
I've used the freebase sample to work from. I've tried to sift thru the essential bits to get something very basic instantiated but obviously missed something or not got it quite right (perhaps in relation to the namespace). I'm simply trying to get this line working
type tp = MyFirstTypeProvider.DataProvider<username="username",password="password",product=prodId>
Intellisense is seeing the DataProvider, but I'm getting squiggly saying that a reference to the type can be found the type could not be found in the assembly.
namespace MyFirstProvider
type internal MyFirstRuntimeInfo(config: TypeProviderConfig) =
let runtimeAssembly = Assembly.LoadFrom(config.RuntimeAssembly)
member val DataContextType = runtimeAssembly.GetType("MyFirstProvider.Runtime.DataContext")
member this.RuntimeAssembly = runtimeAssembly
// This type defines the type provider. When compiled to a DLL, it can be added
// as a reference to an F# command-line compilation, script, or project.
[<TypeProvider>]
type public Types(config: TypeProviderConfig) as this =
inherit TypeProviderForNamespaces()
let bfRuntimeInfo = MyFirstRuntimeInfo(config)
let rootNamespace = "MyFirstProvider"
let defaultUsername = "xxxxxxxxxxx"
let defaultPassword = "yyyyyyyyyy"
let defaultProductId = -1
let defaultToken = "none"
let createDataContext = bfRuntimeInfo.DataContextType.GetMethod("_Create")
let createTypes(username, password, productId, rootTypeName) = let bf = new MyFirstProvider.Requests.Queries(defaultToken)
let schema = new MyFirstProvider.Schema.SchemaConnection(bf)
let rootType = ProvidedTypeDefinition(bfRuntimeInfo.RuntimeAssembly,rootNamespace,rootTypeName,baseType=Some typeof<obj>, HideObjectMethods=true)
let theServiceType = ProvidedTypeDefinition("Service",baseType=Some bfRuntimeInfo.DataContextType, HideObjectMethods=true)
let theServiceTypesClass = ProvidedTypeDefinition("ServiceTypes",baseType=Some typeof<obj>,HideObjectMethods=true)
theServiceTypesClass.AddMembers [ theServiceType ]
rootType.AddMembers [ theServiceTypesClass ]
rootType.AddMembersDelayed (fun () ->
[ yield ProvidedMethod ("GetDataContext", [], theServiceType, IsStaticMethod=true,
InvokeCode = (fun _args -> Expr.Call(createDataContext, [ Expr.Value defaultUsername; Expr.Value defaultPassword; Expr.Value defaultProductId ])))
])
rootType
let MyFirstType = createTypes(defaultUsername, defaultPassword, defaultProductId, "Data")
let paramMyFirstType = ProvidedTypeDefinition(bfRuntimeInfo.RuntimeAssembly, rootNamespace, "DataProvider", Some(typeof<obj>), HideObjectMethods = true)
let usernameParam = ProvidedStaticParameter("username", typeof<string>, defaultUsername)
let passwordParam = ProvidedStaticParameter("password", typeof<string>, defaultPassword)
let productIdParam = ProvidedStaticParameter("productId", typeof<int>, defaultProductId)
do paramMyFirstType.DefineStaticParameters([usernameParam;passwordParam;productIdParam], fun typeName providerArgs ->
let username = (providerArgs.[0] :?> string)
let password = (providerArgs.[1] :?> string)
let productId = (providerArgs.[2] :?> int)
createTypes(username, password, productId, typeName))
do
this.AddNamespace(rootNamespace, [MyFirstType ] )
this.AddNamespace(rootNamespace, [paramMyFirstType ] )
[<assembly:TypeProviderAssembly>]
do()
Many thx in advance.
When I try compiling your type provider and reference it in a script file, the reference #r "provider.dll" is underlined with a red squiggly that says:
The type provider 'MyFirstProvider.Types' reproted an error: The type provider constructor has thrown an exception: Object reference not set to an instance of an object.
You can debug such errors by starting a second instance of Visual Studio, and attaching the debugger to another instance (Debug -> Attach to Process) and opening the script file in the instance being debugged.
In the sample you posted here, the null reference exception occurs on this line:
let createDataContext = bfRuntimeInfo.DataContextType.GetMethod("_Create")
This is trying to access method that does not exist. I think the Freebase sample is relatively complicated starting point (here, it is using an object to represent the "data context" - you might want to follow that pattern, but I think it is easier to build it from scratch rather than adapting an existing code). I think a good starting point might be the Hello World type provider which is a lot simpler and just shows how to generate new types, properties and methods.
I would suggest, if you are looking for a simple example of type provider, to look at the File System type provider This is a good place to start as it has no state and no dependency management to take care of.
As to why this one has a dll it can not find, I think it is because this dll has to be seen from where your type provider's dll is. That is, for instance, in the same directory. (You can try to set "copy local" in the build process?)

iPhone CoreData join

this is my core data model:
I'm trying to get all LanguageEntries from a database for a given category.categoryName and languageset.languageSetName e.g.
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:#"LanguageEntry" inManagedObjectContext:del.managedObjectContext];
[fetchRequest setEntity:entity];
NSString* predicateString = [NSString stringWithFormat:#"Category.categoryName = %# AND LanguageSet.languageSetName = %#",
#"Food", #"English####Spanish"];
fetchRequest.predicate = [NSPredicate predicateWithFormat:predicateString];
NSError *error = nil;
NSArray* objects = [del.managedObjectContext executeFetchRequest:fetchRequest error:&error];
This always returns 0 objects. If I set the predicate string to match on one relationship (e.g. Category.categoryName = Food or languageSet.languageSetName = English####Spanish) it will return data.
This is baffling, can anyone shed some light?
->Ken
Your can't think of Core Data as SQL. There is no such thing as a "join" in Core Data. In this case, your trying to find the intersection of two sets of objects. Close to a join logically but not in the implementation details. And the programming devil is always in the details.
Try using the logical equal "==" like so:
#"Category.categoryName == %# AND LanguageSet.languageSetName == %#"
I believe that will solve your problem.
The data model has a predicate editor hidden way in it. It can help you set up predicates even if you don't embed them in fetches in model itself. Just select an entity, in your case "LanguageEntity", then add a Fetch Request. The edit predicate will appear and you can use the dialog to create the predicate. It will display a textual version of the predicate that you can copy into your code.
The predicate properly wasn't created correctly, you must pass the parameters to predicateWithFormat. It should have been:
fetchRequest.predicate = [NSPredicate predicateWithFormat:#"Category.categoryName = %# AND LanguageSet.languageSetName = %#",
#"Food",
#"English####Spanish"];
In case you were wondering what that does is it puts quotes around the string parameters automatically which are required when using a string in a predicate. When you created the query using NSString's format method that did not put the required quotes in.

UDK "Error, Unrecognized member 'OpenMenu' in class 'GameUISceneClient'"

Upon compiling, I am getting the following error:
C:\UDK\UDK-2010-03\Development\Src\FixIt\Classes\ZInteraction.uc(41) : Error, Unrecognized member 'OpenMenu' in class 'GameUISceneClient'
Line 41 is the following:
GetSceneClient().OpenMenu("ZInterface.ZNLGWindow");
But when I search for OpenMenu, I find that it is indeed defined in GameUISceneClient.uc of the UDK:
Line 1507: exec function OpenMenu( string MenuPath, optional int PlayerIndex=INDEX_NONE )
It looks like I have everything correct. So what's wrong? Why can't it find the OpenMenu function?
From the wiki page on Legacy:Exec Function:
Exec Functions are functions that a player or user can execute by typing its name in the console. Basically, they provide a way to define new console commands in UnrealScript code.
Okay, so OpenMenu has been converted to a console command. Great. But still, how do I execute it in code? The page doesn't say!
More searching revealed this odd documentation page, which contains the answer:
Now then, there is also a function
within class Console called 'bool
ConsoleCommand(coerce string s)'. to
call your exec'd function,
'myFunction' from code, you type:
* bool isFunctionThere; //optional
isFunctionThere = ConsoleCommand("myFunction myArgument");
So, I replaced my line with the following:
GetSceneClient().ConsoleCommand("OpenMenu ZInterface.ZNLGWindow");
Now this causes another error which I covered in my other question+answer a few minutes ago. But that's it!
Not sure if this is your intent, but if you are trying to create a UIScene based on an Archetype that has been created in the UI Editor, you want to do something like this:
UIScene openedScene;
UIScene mySceneArchetype;
mySceneArchetype = UIScene'Package.Scene';
GameSceneClient = class'UIRoot'.static.GetSceneClient();
//Open the Scene
if( GameSceneClient != none && MySceneArchetype != none )
{
GameSceneClient.OpenScene(mySceneArchetype,LocalPlayer(PlayerOwner.Player), openedScene);
}

UDK "Error, 'DefaultMesh': Bad command or expression"

I'm porting UT3 code to UDK, and I am getting the following compile error with the UDK compiler:
C:\UDK\UDK-2010-03\Development\Src\FixIt\Classes\ZPawn.uc(25) : Error, 'DefaultMesh': Bad command or expression
The ZPawn class extends UTPawn.
Line 25 is the following:
DefaultMesh = SkeletalMesh(DynamicLoadObject(ZBotOwner(Owner).MeshToUse, class'SkeletalMesh'));
Where did DefaultMesh go in UDK?
The SkeletalMesh is part of the Mesh Component in a Pawn:
Begin Object Class=SkeletalMeshComponent name=Mesh01
SkeletalMesh=SkeletalMesh'pawnPackage.Meshes.mySkeletalMesh'
AnimTreeTemplate=AnimTree'pawnPackage.Anims.myAnimTree'
PhysicsAsset=PhysicsAsset'pawnPackage.Physics.myPhysicsAsset'
AnimSets(0) =AnimSet'pawnPackage.Anims.myAnimSet'
End Object
Mesh=Mesh01
Components.Add(Mesh01)
Well just to be clear, the line change you will want will be this:
Mesh = SkeletalMesh(DynamicLoadObject(ZBotOwner(Owner).MeshToUse, class'SkeletalMesh'));
Assuming of course your ZBot is all set up correctly.
Also I'm assumign that this is in default properties? Don't forget to add it to your components
Components.Add(Mesh);

Resources