Filter array using predicate - iphone

I need to filter following array with status equal to "U" and i have used following.
NSArray *result = [alertModified.senders filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:#"(subscriptions.status = %#)",#"U"]];
But I'm getting empty arrays.
Please help me on filtering this?
Array String:
(senderCode = CPFB, senderName = CPFB, forSenderLevel = 0, subscriptions = (
"correspondenceListId = 102,status = S,senderCode = AA,subject = Letter,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ",
"correspondenceListId = 103,status = U,senderCode = BB,subject = Nomination Letters,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ",
"correspondenceListId = 104,status = U,senderCode = AA,subject = Yearly statements,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = ",
"correspondenceListId = 105,status = U,senderCode = BB,subject = All Future Letters,retentionPeriod = 0, uniqueBillIdentifier = (null),senderResponseStatus = (null),subscriptionDate = ,effectiveDate = "))

In your example you should be filtering the subscription list itself, not the whole senders. You have to apply the filter to each sender. Try changing your filter line to this and check if it gives you results:
NSArray *result = [[alertModified.senders objectAtIndex:0].subscriptions filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:#"(status = %#)",#"U"]];

Related

Entry data form

I'm creating a data entry form to a database sheet, previously I've managed to create a single cell data entry form. But now I'm going to create a data entry form that is entered in the range B6:N10. How do I modify it?
function SIMPAN1() {
var Sheet = SpreadsheetApp.openById("1hnezkq89bgVUvimYDdAfWDVY01f7ekFN3T6TY3Ui6oA");
var sheetInput = Sheet.getSheetByName('INPUT');
var sheetDb = Sheet.getSheetByName('DATABASE');
var lastRow = sheetDb.getRange("B1").getDataRegion().getLastRow();
lastRow += 1
var data1 = [[tgl1 = sheetInput.getRange('B6').getValue(),
nama1 = sheetInput.getRange('C6').getValue(),
kls1 = sheetInput.getRange('D6').getValue(),
srthfl1 = sheetInput.getRange('E6').getValue(),
aythfl1 = sheetInput.getRange('F6').getValue(),
nilaithfz1 = sheetInput.getRange('G6').getValue(),
jldsrt1 = sheetInput.getRange('H6').getValue(),
hlmayt1 = sheetInput.getRange('I6').getValue(),
mtri1 = sheetInput.getRange('J6').getValue(),
nilaitrtl1 = sheetInput.getRange('K6').getValue(),
prgst1 = sheetInput.getRange('L6').getValue(),
prgda1 = sheetInput.getRange('M6').getValue(),
ket1 = sheetInput.getRange('N6').getValue(),]];
sheetDb.getRange("B" + lastRow + ":N" + lastRow).setValues(data1);
}
Try this:
function SIMPAN1() {
const ss = SpreadsheetApp.openById("ssid");
const ish = ss.getSheetByName('INPUT');
const dsh = ss.getSheetByName('DATABASE');
const ivs = ish.getRange(6, 2, 1, 13).getValues();
dsh.getRange(dsh.getLastRow() + 1, 2, ivs.length, ivs[0].length).setValues(ivs);
}

Filtering data from Struct in Matlab

S.o = [{'A'} ,{'B'}, {'C'}];
S.p.q = [{'q1'}, {'q2'}, {'q3'}];
S.p.q.a = [-1,-2,-3];
S.p.q.b = [10,20,30];
How do i create another struct (S_filter) in Matlab for S.o = 'A' or 'C' only:
S_filter.o = [{'A'} ,{'C'}];
S_filter.p.q = [{'q1'}, {'q3'}];
S_filter.p.q.a = [-1,-3];
S_filter.p.q.b = [10,30];
Thanks

Swift, dictionary parse error

I'm using an API to get weather condition and the retrieved dict is
dict = {
base = stations;
clouds = {
all = 92;
};
cod = 200;
coord = {
lat = "31.23";
lon = "121.47";
};
dt = 1476853699;
id = 1796231;
main = {
"grnd_level" = "1028.63";
humidity = 93;
pressure = "1028.63";
"sea_level" = "1029.5";
temp = "73.38";
"temp_max" = "73.38";
"temp_min" = "73.38";
};
name = "Shanghai Shi";
rain = {
3h = "0.665";
};
sys = {
country = CN;
message = "0.0125";
sunrise = 1476827992;
sunset = 1476868662;
};
weather = (
{
description = "light rain";
icon = 10d;
id = 500;
main = Rain;
}
);
wind = {
deg = "84.50239999999999";
speed = "5.97";
};
}
If I want the value of humidity, I just use
let humidityValue = dict["main"]["humidity"] and it works.
But the problem is I also want to get the value of description in weather
when I used let dscptValue = dict["weather"]["description"]
it retrieved nil.
How's that? and I notice there are two brackets around weather .I'm not sure whether it is the same with the statement without brackets.
weather = (
{
description = "light rain";
icon = 10d;
id = 500;
main = Rain;
}
);
How to get the value of description?
weather keys contains Array of Dictionary not directly Dictionary, so you need to access the first object of it.
if let weather = dict["weather"] as? [[String: AnyObject]], let weatherDict = weather.first {
let dscptValue = weatherDict["description"]
}
Note: I have used optional wrapping with if let for preventing crash with forced wrapping.
Weather is an array of dictionaries.
dict["weather"][0]["description"]
may give you the expected result.

Crystal Reports Leaving out parameter

I have a crystal report that I am modifying the record selection formula. I have a parameter "Inventory_Class" that can have 3 values 0, 1 or 2. If set to 1 I want my DB field "NON_Controllable" that is binary field to select all False records, if the parameter is set to 2 then I want all True records but if the incoming parameter is set to 0 then I don't want to filter on the DB field "NON_Controllable" at all. I can get formula to work when parameter is set to 1 and 2 selecting Non_Controllable false and true records but when the parameter is set to 0 my report returns no records when it should be returning all records.
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD} and
IF ({?INVENTORY_CLASS} = 1) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = FALSE
ELSE IF ({?INVENTORY_CLASS} = 2) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = TRUE
ELSE IF ({?INVENTORY_CLASS} = 0) THEN
NOT {Inventory_Cat_Header.NON_CONTROLLABLE}
How can I modify this formula to work?
you can try passing the parameters for each conditions instead.
IF
({?INVENTORY_CLASS} = 1) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = FALSE and
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}
ELSE IF
({?INVENTORY_CLASS} = 2) THEN
{Inventory_Cat_Header.NON_CONTROLLABLE} = TRUE and
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}
else
{Inventory_Catalog.PROP_NO} = {?PROPERTY} and
{Inventory_Cat_Header.INVEN_TYPE_CD} = {?TYPE} and
{Inventory_Cat_Header.OPER_BUS_SEG_CD} = {?OPER_BUS_SEG} and
{Inventory_Catalog.SURP} = {?SURP} and
{Inventory_Catalog.COND_CD} = {?CONDITION} and
{Inventory_Cat_Header.INVEN_ID} = {?INVEN_ID} and
{Inventory_Catalog.SER_NO} = {?SERIAL} and
{Inventory_Cat_Header.BUS_UNIT_CD} = {?BUS_UNIT_CD}

Not sure of the value being retrieved from NSDictionary

I want to retrive a value from a NSDictionary.
Here is a snippet of code:
NSDictionary *metadataDict = [representation metadata];
NSLog(#"%#",metadataDict);
"DateTimeOriginal" is the value I want to retrieve from the following output.
{
ColorModel = RGB;
DPIHeight = 72;
DPIWidth = 72;
Depth = 8;
Orientation = 6;
PixelHeight = 1936;
PixelWidth = 2592;
"{Exif}" = {
ApertureValue = "2.970854";
ColorSpace = 1;
ComponentsConfiguration = (
1,
2,
3,
0
);
DateTimeDigitized = "2011:09:28 09:35:36";
DateTimeOriginal = "2011:09:28 09:35:36";
ExifVersion = (
2,
2,
1
);
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666667";
FNumber = "2.8";
Flash = 24;
FlashPixVersion = (
1,
0
);
FocalLength = "3.85";
ISOSpeedRatings = (
320
);
MeteringMode = 5;
PixelXDimension = 2592;
PixelYDimension = 1936;
SceneCaptureType = 0;
SensingMethod = 2;
Sharpness = 2;
ShutterSpeedValue = "3.9112";
SubjectArea = (
1295,
967,
699,
696
);
WhiteBalance = 0;
};
"{GPS}" = {
Latitude = "37.54216666666667";
LatitudeRef = N;
Longitude = "126.95";
LongitudeRef = E;
TimeStamp = "01:19:05.00";
};
"{TIFF}" = {
DateTime = "2011:09:28 09:35:36";
Make = Apple;
Model = "iPhone 4";
Orientation = 6;
ResolutionUnit = 2;
Software = "4.3.5";
XResolution = 72;
YResolution = 72;
"_YCbCrPositioning" = 1;
};
}
I know it's long but I tried these three and it still would not work.
NSLog(#"valueForKey %#", [metadataDict valueForKey:#"DateTimeOriginal"]);
NSLog(#"valueForKeyPath %#", [metadataDict valueForKeyPath:#"DateTimeOriginal"]);
NSLog(#"objectForKey %#", [metadataDict objectForKey:#"DateTimeOriginal"]);
Does anyone know what kind of datatype is in the NSDictionary and how I can retrieve it?
Thanks much.
Above project link:
http://dl.dropbox.com/u/12439052/TheK2.zip
What you're really looking for is
NSDictionary *exif = [metadataDict objectForKey:#"{Exif}"];
NSLog(#"DateTimeOriginal: %#", [exif objectForKey:#"DateTimeOriginal"]);
If you read the output from your first log, you'll see that the key you want is actually inside another dictionary which has the key "{Exif}". Also, -objectForKey: is the better method here to use rather than -valueForKey: (the latter is for generic KVO, the former is the real dictionary object accessor).
Try this one:
NSString *DateTimeOriginal=[[metadataDict objectForKey:#"{Exif}"]objectForKey:#"DateTimeOriginal"];
During Response Value of lines keep in mind
{ .......... } indicates dictionary.
(............) indicates array.
Dictionary always have key with it like somename = "value in it".
Array has value seperated by comma like a , b , c .....
Now it is possible it may have array into dictionary like { SubjectArea = ( 1295,967,699,696);} and vice versa.