RKClient: how do do a simple PUT of xml body - restkit

I'm using RestKit, and have yet to come across how to do a simple PUT of a body like this:
<parameters></parameters>
Can someone please give a code example?

This is kind of a confusing PUT since your query parameter is actually titled "parameters". Are you sure that was the intention? Try something like this.
NSDictionary* params = [NSDictionary dictionaryWithObject:#"" forKey:#"parameters"];
[[RKClient sharedClient] put:yourURL params:params delegate:self];
Of course you will need to have RestKit imported, and your .h file must accept < RKRequestDelegate >. I hope that gets you on the right track.
You may also want to look at this SO question, however I haven't implemented the suggested solution so I can't ascertain as to its efficacy.

Related

How to Get FHIR Photo for Patient from a URL

Consider the FHIR Patient data at http://spark.furore.com/fhir/Patient/f201.
How can I get the photo object referenced therein at URL "binary/#f006"??
I would have thought an HTTP GET on http://spark.furore.com/fhir/binary/#f006 would have done it, but alas...
the data there is wrong. Your conversion to the get was correct, but you ended up with a wrong URL because the reference is wrong in the first place.
It should say: url="Binary/f006" which would equate to a get of http://spark.furore.com/fhir/Binary/f006. That doesn't work either, which is another error in the way things are defined.
See http://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_item_id=6107 for follow ups
Yes, this reference is outdated, and we are not distributing Binaries currently as part of the examples in the FHIR specification. Our server Spark loads the examples from the specification when we initialize the database, hence the images are not there.
For now, I have uploaded the correct image to Binary/f006 and have updated the link in Patient/f201, so things should work now. When we re-initialize the database (we don't do this often), these changes will be reversed, but a simple PUT to Binary/f006 and an update of Patient/f201 will fix this of course.

How to change generated files output path in Docpad?

I want to do something like what docpad-plugin-dateurls does but in the context of static site generation.
I need, for example, to map the file /src/documents/posts/2013-09-10-post-title.html to the url http://localhost:9778/posts/2013/09/10/post-title.html
Which would be the best approach to acomplish this requirement?
You would do something like this: https://github.com/Greduan/eduantech.docpad/blob/d5e97638331ab24730d3331b9fbcc30cf1d46dcc/docpad.coffee#L45-L49
You would modify it for your needs but it does what you need I think. :)
I finally implemented this by setting the outPath of each document in the renderBefore event.
See here: https://github.com/gschuager/blog/blob/7451fbcb829ad93154d24b281c7e8e30d3a0edac/docpad.js#L83

Xcode - how to insert code into a specific location

I have a standard piece of NSUserDefault code that I want to merge into a number of pages at compile time. Unlike Include they need the code inserted into a specific location.
I presume Xcode supports this? e.g.
-(void)viewDidLoad {
[INSERT CODE HERE]
}
Why not put the code into a method and call it where appropriate?
Define a function or method and call as you would normally. Use search and replace, if needed.
Note that you could do this:
- (void)viewDidLoad
{
#include "some_file.h"
}
…but that's the kind of style i would (personally) reject from my codebases.
ps: A more detailed description could help you get a more exact answer.

RestKit many-to-many with Core Data: it works, but am I doing it right?

I'm new to RestKit. I'm trying to map a many-to-many relationship, between entities Space and User. For the purposes of this question, assume all the Space objects are in the Core Data store correctly already.
In the REST API, I can make a single call to get all the users for a given space. First of all, when I initialise my network fetching class, I set up a mapping appropriate for parsing a list of users:
RKManagedObjectMapping *teamMapping = [RKManagedObjectMapping mappingForEntity:[NSEntityDescription entityForName:#"User" inManagedObjectContext:self.manager.objectStore.primaryManagedObjectContext] inManagedObjectStore:self.manager.objectStore];
[teamMapping mapKeyPath:#"id" toAttribute:#"userID"];
[teamMapping mapKeyPath:#"name" toAttribute:#"name"];
teamMapping.primaryKeyAttribute = #"userID";
[self.manager.mappingProvider setMapping:teamMapping forKeyPath:#"users.user"];
Then, to populate the links for the users to the spaces, I do this:
NSArray *spaces = [self.managedObjectContext executeFetchRequest:[NSFetchRequest fetchRequestWithEntityName:#"Space"] error:nil];
for (QBSpace *space in spaces)
{
[self.manager loadObjectsAtResourcePath:[NSString stringWithFormat:#"space/%#/users", space.wikiName] usingBlock:^(RKObjectLoader *loader) {
loader.onDidLoadObjects = ^(NSArray *objects){
space.team = nil;
for (QBUser *user in objects)
{
[space addTeamObject:user];
}
};
}];
}
That is, I manually add the space->user link based on the returned array of objects.
Is that the correct way to do it? It seems to work fine, but I'm worried I'm missing a trick with regards to RestKit doing things automatically.
The returned XML for the file in question looks like
<users type="array">
<user>
<id>aPrimaryKey</id>
<login>loginName</login>
<login_name warning="deprecated">loginName</login_name>
<name>Real Name</name>
</user>
So there is nothing in the returned file to indicate the space that I'm trying to link to: I passed that in in the URL I requested, but there's nothing in the returned document about it, which is why I came up with this block based solution.
To all the RestKit users, does this look like an acceptable way to form many-to-many links?
If it works, it's ok?
You could think about having a Space custom ManagedObject. Have it respond to the RKObjectLoaderDelegate.
Then, when you get the reply, you could trigger the loadAtResourcePath from within its
objectLoader:didLoadObject:(id)object or objectLoader:didLoadObjectDictionary:
methods.
You could also make your Space class respond to the delegates from User and then tie them into their space at that point?
It might be better, but that would depend on what you are trying to achieve. Food for thought anyway. :)

AVMutableAudioMix simple question

just want to understand , what exactly I can do with this AVMutableAudioMix class, once I will insert PlayerItems (Assets) in to the AudioMix, can I play them one at the time or some of them at the same time with AVPlayer and change the parameters dynamically?
I think you might be visualizing it incorrectly. An AVMutableAudioMix instance is actually a property on the AVPlayerItem class. First grab the track of the asset using tracksWithMediaType: and create an AVMutableAudioMixInputParameters instance using audioMixInputParametersWithTrack:. Set any audio properties on that inputparameters instance, (for instance setVolume:atTime).
Then you need to add the input parameters onto an AVMutableAudioMix instance. Then you need to add this to an player item. I know this sounds confusing, but this is exactly how AVFoundation works with just about everything. There's terms flying around all over the place, but pretty much everything has a hierarchy.
So the general hierarchy is this: player->playerItem->audioMix->inputParameters. The code to ramp down the volume from the 5 to 7 second mark should look something like this:
AVAssetTrack *audioTrack = [[self.player.currentItem.asset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
AVMutableAudioMixInputParameters *params = [AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:audioTrack];
[params setVolumeRampFromStartVolume:1.0 toEndVolume:0.5 timeRange:CMTimeRangeMake(CMTimeMake(5,1), CMTimeMake(2,1))];
AVMutableAudioMix *audioMix = [AVMutableAudioMix audioMix];
audioMix.inputParameters = [NSArray arrayWithObject:params];
self.player.currentItem.audioMix = audioMix;
As far as doing this dynamically, you can, but only with local files (as opposed to streaming from the internet). I would probably try to keep this audioMix as an ivar and try resetting the params every time you want something to happen. If that doesn't work, you may have to create an instance of AVMutableAudioMix every time, not sure.
Also see this post and this.

Resources